I have a custom page template created for my homepage. I have this set to the Static Homepage under the Reading settings. I want to be able to show the last three news posts from my Blog page which is titled News.
I have tried the following loop but it is pulling the content from the custom page content:
<?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; ?>
I need to show the post title, date, excerpt, and read more link.
I'm also building this off the current version of underscores theme, if that helps you understand why it's calling for the template parts.
Any help would be greatly appreciated.
query_posts()
before displaying it. Please take a look at the official documentation on how to query for specific category and number of posts that you were looking for.