Skip to main content
1 of 2

Loop on front-page.php

I'm trying to load the 3 latests posts on my homepage. I'm an utter novice but I seem to be making progress.

This is my code (below). At the minute each post has a title of "Home", I understand that is because the homepage is the main query?

<?php $latest_blog_posts = new WP_Query( array( 'posts_per_page' => 3 ) ); if ( $latest_blog_posts->have_posts() ) : while ( $latest_blog_posts->have_posts() ) : $latest_blog_posts->the_post(); get_template_part('loop'); endwhile; endif; ?> 

So how would I amend this code so it pulls in the 3 latest posts from the blog using loop.php?

I also having a Custom Post Type which uses a different page/loop. But I assume once this is working it would just be a matter of swapping the 'loop' for 'loop-2' to get that working using the same code?

Hope someone can help with this. It's one step forward, two steps back at the minute for me!