我一直在学习本教程:http://www.wpbeginner.com/wp-themes/create-custom-single-post-templates-for-specific-posts-or-sections-in-wordpress/
为“post”类型的网页创建自定义模板。本教程要求复制single的内容。将php转换为一个空白页,在其中我定义了一个模板名称(在本例中是“Series”)。
我已经成功地将其作为可选选项显示在“编辑帖子”屏幕的“帖子属性”部分,但当我选择它并预览帖子时,我遇到了500个内部服务器错误。
起初我认为这是由于某种类型的php语法造成的,但在清理了开始和结束标记后,我看不到
我正在使用HTML5空白主题。代码如下:
<?php
/*
* Template Name: Series
* Template Post Type: post, page, product
*/
get_header();
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post();
/*
* Include the post format-specific template for the content. If you want to
* use this in a child theme, then include a file called content-___.php
* (where ___ is the post format) and that will be used instead.
*/
get_template_part( \'content\', get_post_format() );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
// Previous/next post navigation.
the_post_navigation( array(
\'next_text\' => \'<span class="meta-nav" aria-hidden="true">\' . __( \'Next\', \'twentyfifteen\' ) . \'</span> \' .
\'<span class="screen-reader-text">\' . __( \'Next post:\', \'twentyfifteen\' ) . \'</span> \' .
\'<span class="post-title">%title</span>\',
\'prev_text\' => \'<span class="meta-nav" aria-hidden="true">\' . __( \'Previous\', \'twentyfifteen\' ) . \'</span> \' .
\'<span class="screen-reader-text">\' . __( \'Previous post:\', \'twentyfifteen\' ) . \'</span> \' .
\'<span class="post-title">%title</span>\'
) );
// End the loop.
endwhile;
?>
</main><!-- .site-main -->
</div><!-- .content-area -->
<?php get_footer(); ?>