关于如何使用single.php WordPress文件的一些信息?

关于如何使用single.php WordPress文件的一些信息?,php,wordpress-theming,wordpress,Php,Wordpress Theming,Wordpress,我是WordPress主题开发方面的新手,我对显示一篇文章的单个php文件有些怀疑 <!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: --> <section id="blog-posts"> <header class="header-sezione"> <?php // Start the Loop. whil

我是WordPress主题开发方面的新手,我对显示一篇文章的单个php文件有些怀疑

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
我从我的index.php文件开始创建了这个single.php文件:

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
导言 导言文本

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
我不明白的是,在执行此操作时,您到底要做什么:

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
get_template_part( 'content', get_post_format() );
在阅读文档()时,我似乎了解到它将预定义的模板加载到我的主题中(就像放入主题中的代码片段)

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
我认为这会将打印我文章的代码放在页面上(标题,标题下是作者姓名,日期,文章文本,最后是类别和添加评论链接)

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
实际上,我是否将content.php文件放在声明前面代码的位置

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
Tnx

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
安德烈

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
这是真的吗?安德里亚

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
你说得对。这相当于“包含”

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
打破这个

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
get_template_part( 'content', get_post_format() );

get_template_part   // is calling a function to locate the template partial aka include

'content'    // this is the base slug. 
     //  Think of it like a root word as opposed to a suffix.

get_post_format()    //  is saying get the particular content "partial" or "include"
这是在做什么? 假设您在一篇“视频”格式的帖子上(您知道,在右侧创建帖子时,您可以选择“帖子格式”)

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
标准 音频 在一边 聊天 画廊 形象 链接 引用 地位 录像带

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
好的,假设你点击了“视频”的单选按钮。所以这篇文章包含了一段视频

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
现在,回到“获取模板”部分。。。 这将首先查找名为“content video.php”的文件 如果您还没有创建一个,那么它将返回默认文件“content.php”

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
这就是为什么在“获取模板”部分中有第二项。 因为它为您提供了一种“回退”,以防丢失特定的模板,所以它可以查找“默认”模板

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
它将查找文件的顺序如下

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
如果您使用的是子主题-- 它将首先在您的子主题文件夹/目录中查找 content-video.php content.php

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
然后,如果找不到它,它将在父主题文件夹中查找文件 content-video.php content.php

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
您正在使用子主题,对吗?>?>

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
你可以在任何地方使用它的额外美丽。。。 甚至有条件地包括在内

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
例如,如果您想提供一个注册eNews的机会,但前提是有人正在阅读某个特定类别的帖子。。。你可以做以下事情

<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>
if (in_category( '327' )){
    get_template_part('partials/enewssignup');
}

这将引用/partials文件夹中的文件enewssignup.php。

完美的解释,tnx太多了
<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">

    <header class="header-sezione">

        <?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 called content-___.php
                 * (where ___ is the post format) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

                // Previous/next post navigation.
                //twentyfourteen_post_nav();

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) {
                    comments_template();
                }
            endwhile;
        ?>
    </header>

    <!-- Qui viene visualizzato il singolo articolo -->

</section>

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>

    <div class="row">
        <?php
        // 'My_Widgtet_Area' area, where the id is called:
        if (is_active_sidebar('partner-slide')) : ?>

        <div id="widget-sidebar">
            <ul>
                <?php dynamic_sidebar('partner-slide'); ?>
            </ul>
        </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>