【发布时间】:2012-01-25 12:28:44
【问题描述】:
除了标准之外,我还设置了使用库和视频的帖子格式。我正在编辑 loop-single.php 为每种帖子格式提供不同的布局,但我要为每种帖子格式包含 get_template_part。
这就是我所拥有的:
<?php
/**
* The loop that displays a single post.
*
* The loop displays the posts and the post content. See
* http://codex.wordpress.org/The_Loop to understand it and
* http://codex.wordpress.org/Template_Tags to understand
* the tags used in it.
*
* This can be overridden in child themes with loop-single.php.
*
* @package WordPress
* @subpackage Twenty_Ten
* @since Twenty Ten 1.2
*/
?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php
if ( has_post_format( 'gallery' )) {
// code to display the gallery format post here
get_template_part( 'news' 'gallery' ); // News Gallery Template (news-gallery.php)
} else if (has_post_format('video')) {
// stuff to display the video format post here
get_template_part( 'news' 'video' ); // News Gallery Template (news-video.php)
}else {
// code to display the normal format post here
get_template_part( 'news' 'standard' ); // News Gallery Template (news-standard.php)
}
<?php endwhile; // end of the loop. ?>
?>
我在测试时出现错误:
解析错误:语法错误,第 26 行 /home/judddev/public_html/pitch/wp-content/themes/pitch/loop-single.php 中的意外 T_CONSTANT_ENCAPSED_STRING
任何帮助将不胜感激。
【问题讨论】:
-
get_template_part('新闻''画廊'); // 新闻图库模板 (news-gallery.php) Apprently