试图创建自定义“POST”模板,收到500内部服务器错误

时间:2018-03-09 作者:user138326

我一直在学习本教程: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(); ?>

1 个回复
SO网友:Alex Sancho

这种情况下的第一步是启用WP\\u DEBUG以获取有关错误的更多信息,您可以在此处了解更多信息https://codex.wordpress.org/WP_DEBUG

结束

相关推荐

Admin Theme customization

我遵循wordpress codex网站上关于通过插件创建管理主题的说明。我激活了插件,但我的样式表没有包含在<head>.. 这是我的代码:add_action( \'admin_init\', \'kd_plugin_admin_init\' ); add_action( \'admin_menu\', \'kd_plugin_admin_menu\' ); function kd_plugin_admin_init() { /* Register