Wordpress:使用get\u template\u部分发布格式single-loop.php
除了标准之外,我还设置了使用post格式库和视频。我正在编辑loop-single.php,为每种帖子格式提供不同的布局,但我将为每种帖子格式包含get_template_部分 这就是我所拥有的:Wordpress:使用get\u template\u部分发布格式single-loop.php,php,wordpress,Php,Wordpress,除了标准之外,我还设置了使用post格式库和视频。我正在编辑loop-single.php,为每种帖子格式提供不同的布局,但我将为每种帖子格式包含get_template_部分 这就是我所拥有的: <?php /** * The loop that displays a single post. * * The loop displays the posts and the post content. See * http://codex.wordpress.org/The_Lo
<?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/juddev/public\u html/pitch/wp content/themes/pitch/loop-single.php中出现意外的T_常量_封装_字符串
任何帮助都将不胜感激。在
获取模板部分('news','gallery') 添加逗号:
get_template_part( 'news', 'gallery' );
here ___^
在oher调用中,也可以调用get\u template\u 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; ?>
只需从以下位置切换:
<?php endwhile; ?>
?>
?>
对此
?>
<?php endwhile; ?>
?>
get_template_part('news''gallery');//新闻库模板(News Gallery.php)ApprentlyNew error出现解析错误:语法错误,意外“谢谢”。最后并不是这样。我把钥匙放错地方了。我将发布答案,请稍候。好的,我的答案对您有用,然后单击向右箭头接受我的答案。ThanksNew error出现解析错误:语法错误,意外'