在二十个主题的首页上显示评论

时间:2017-05-27 作者:user3506776

我想在静态home page of a site 使用2017主题。我已经在设置和页面上对其进行了配置,但没有显示任何内容。

我错过什么了吗?

1 个回复
最合适的回答,由SO网友:Vinod Dalvi 整理而成

要做到这一点,你必须创建头版。php文件中的子主题的十七个主题在您的网站上,并添加以下修改后的代码。

<?php
/**
 * The front page template file
 *
 * If the user has selected a static page for their homepage, this is what will
 * appear.
 * Learn more: https://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty_Seventeen
 * @since 1.0
 * @version 1.0
 */

get_header(); ?>

<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">

        <?php // Show the selected frontpage content.
        if ( have_posts() ) :
            while ( have_posts() ) : the_post();
                get_template_part( \'template-parts/page/content\', \'front-page\' );

                // 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;
            endwhile;
        else : // I\'m not sure it\'s possible to have no posts when this page is shown, but WTH.
            get_template_part( \'template-parts/post/content\', \'none\' );
        endif; ?>

        <?php
        // Get each of our panels and show the post data.
        if ( 0 !== twentyseventeen_panel_count() || is_customize_preview() ) : // If we have pages to show.

            /**
             * Filter number of front page sections in Twenty Seventeen.
             *
             * @since Twenty Seventeen 1.0
             *
             * @param $num_sections integer
             */
            $num_sections = apply_filters( \'twentyseventeen_front_page_sections\', 4 );
            global $twentyseventeencounter;

            // Create a setting and control for each of the sections available in the theme.
            for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) {
                $twentyseventeencounter = $i;
                twentyseventeen_front_page_section( null, $i );
            }

    endif; // The if ( 0 !== twentyseventeen_panel_count() ) ends here. ?>

    </main><!-- #main -->
</div><!-- #primary -->

<?php get_footer();

结束
在二十个主题的首页上显示评论 - 小码农CODE - 行之有效找到问题解决它

在二十个主题的首页上显示评论

时间:2017-05-27 作者:user3506776

我想在静态home page of a site 使用2017主题。我已经在设置和页面上对其进行了配置,但没有显示任何内容。

我错过什么了吗?

1 个回复
最合适的回答,由SO网友:Vinod Dalvi 整理而成

要做到这一点,你必须创建头版。php文件中的子主题的十七个主题在您的网站上,并添加以下修改后的代码。

<?php
/**
 * The front page template file
 *
 * If the user has selected a static page for their homepage, this is what will
 * appear.
 * Learn more: https://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty_Seventeen
 * @since 1.0
 * @version 1.0
 */

get_header(); ?>

<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">

        <?php // Show the selected frontpage content.
        if ( have_posts() ) :
            while ( have_posts() ) : the_post();
                get_template_part( \'template-parts/page/content\', \'front-page\' );

                // 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;
            endwhile;
        else : // I\'m not sure it\'s possible to have no posts when this page is shown, but WTH.
            get_template_part( \'template-parts/post/content\', \'none\' );
        endif; ?>

        <?php
        // Get each of our panels and show the post data.
        if ( 0 !== twentyseventeen_panel_count() || is_customize_preview() ) : // If we have pages to show.

            /**
             * Filter number of front page sections in Twenty Seventeen.
             *
             * @since Twenty Seventeen 1.0
             *
             * @param $num_sections integer
             */
            $num_sections = apply_filters( \'twentyseventeen_front_page_sections\', 4 );
            global $twentyseventeencounter;

            // Create a setting and control for each of the sections available in the theme.
            for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) {
                $twentyseventeencounter = $i;
                twentyseventeen_front_page_section( null, $i );
            }

    endif; // The if ( 0 !== twentyseventeen_panel_count() ) ends here. ?>

    </main><!-- #main -->
</div><!-- #primary -->

<?php get_footer();