我有一个为我的主页创建的自定义页面模板。我把它设置为阅读设置下的静态主页。我想能够显示我博客页面上最后三篇标题为“新闻”的新闻帖子。
我尝试了以下循环,但它正在从自定义页面内容中提取内容:
<?php
if ( have_posts() ) :
if ( is_home() && ! is_front_page() ) : ?>
<header>
<h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
</header>
<?php
endif;
/* Start the Loop */
while ( have_posts() ) : the_post();
get_template_part( \'template-parts/content\', get_post_format() );
endwhile;
the_posts_navigation();
else :
get_template_part( \'template-parts/content\', \'none\' );
endif; ?>
我需要显示文章标题、日期、摘录和阅读更多链接。如果这有助于你理解为什么需要模板部分,我也在根据下划线主题的当前版本构建这个。
任何帮助都将不胜感激。