How to feature your recent WordPress posts on home page

With content marketing being all the rage, you are writing blog posts consistently. It’s a great user experience to display your most recent posts, right on the homepage.

Your audience will find your latest posts easily. Your home page will have a refreshed look every time new posts are put out.

Here are two examples of websites that have taken this approach.

how to display recent posts on homepage problogger
Pro blogger website showing the latest blog posts on the home page
how to display recent posts on homepage xosarah
XoSarah’s website showing the latest blog posts on the home page

So by now, you are convinced about this tactic to get your audience to your latest posts. But what if your theme doesn’t support this feature? What if you don’t want to clog your WordPress admin with yet another plugin.

Well, fret no more. I’m going to show you an easy way to get two of the recent blog posts with a featured image, to show up on the home page. With a little bit of code and a cup of hot masala chai, let’s get your latest posts on the home page. No plugins will be harmed:-)

Here is what the end result will look like.

How to feature recent posts on home page
Screenshot of two recent posts on my home page

Steps To Feature Your Recent WordPress Posts On Home Page

  1. Open the front-page.php file from your WordPress theme directory.
  2. Go to the location where you want the recent posts to be displayed in the .php file.
  3. Copy and Paste the code snippet and make the necessary changes to suit your needs and theme structure.
<?php 
/* Code snippet to feature two recent posts on home page */

//2 is the number of posts to display on the home page
$args = array( 'numberposts' => 2 ); 
$lastposts = get_posts( $args );

//change the div class based on your theme structure
echo '<div class="article-container">'; 
foreach($lastposts as $post) : setup_postdata($post); 
echo '<article>';
if (has_post_thumbnail()){ ?>

//getting the featured image of the post
<figure class="featured-image"> 
<a href="<?php echo esc_url(get_permalink());?>" rel="bookmark">
<?php the_post_thumbnail(); ?>
</a>
</figure>
<?php } ?> 

//getting the post title
<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
<?php echo '</article>';
endforeach; 
echo '</div>';?>

That’s it. Your most recent posts with the featured image will be displayed on the home page.

I hope this article helped you to understand how to feature the recent posts on the home page with no plugins. I used this quick and easy method to get my recent posts on my home page and on several client projects.

I’d love to hear back from you when you try this out on your client projects.

TELL ME: What worked and what tweaks did you make to customize it for your theme?

Subscribe by email
If you're an email kind of person, sign up below to get the latest blog posts in your inbox! You might get some free WordPress goodies from me:-).
I promise not to spam you or share your address.

Client Love

Femy is a diligent, self motivated hard worker. She tackles all assignments with energy and enthusiasm. Femy was always easy to work with and followed directions very well. Her work was always timely and of professional quality.

William Farris Director of Software, Samsung Telecoms