How to Exclude Latest Post From the WordPress Post Loop

Do you want to exclude the latest post from the WordPress post loop?

This lets you choose whether or not you want your latest blog post to display on your home page, or other pages where your blog posts are featured.

In this article, we’ll show you how to exclude the latest post from the WordPress post loop.

How to exclude latest post from the WordPress post loop

Why Exclude the Latest Post from the WordPress Post Loop?

Excluding the latest post while displaying other articles can be helpful when you’re editing your theme and want more control over how the first post displays.

For example, your first post may have different formatting, or not be relevant to be listed in your default WordPress blog.

With that said, let’s show you how to exclude the latest post from the WordPress post loop using two different methods.

Method 1. Exclude Latest Post from WordPress Post Loop by Adding New WordPress Function

The easiest way to exclude the latest post from the post loop is by adding code to your WordPress files. If you haven’t done this before, then check out our guide on how to copy and paste code in WordPress.

You can add the code snippet below to your functions.php file, in a site-specific plugin, or by using a code snippets plugin.

function wpsites_exclude_latest_post( $query ) {
	if ( $query->is_home() && $query->is_main_query() ) {
		$query->set( 'offset', '1' );

add_action( 'pre_get_posts', 'wpsites_exclude_latest_post', 1 );

This code will exclude the latest post from displaying on your home page loop. The offset is set to one, so only the first post will be hidden.

add_action('pre_get_posts', 'myprefix_query_offset', 1 );
function myprefix_query_offset(&$query) {

    //Before anything else, make sure this is the right query...
    if ( ! $query->is_home() ) {

    //First, define your desired offset...
    $offset = 1;
    //Next, determine how many posts per page you want (we'll use WordPress's settings)
    $ppp = get_option('posts_per_page');

    //Next, detect and handle pagination...
    if ( $query->is_paged ) {

        //Manually determine page query offset (offset + current page (minus one) x posts per page)
        $page_offset = $offset + ( ($query->query_vars['paged']-1) * $ppp );

        //Apply adjust page offset
        $query->set('offset', $page_offset );

    else {

        //This is the first page. Just use the offset...


This code snippet will set the offset again to 1. But, it also adds the offset and introduces pagination. Here it tells our blog archive to skip the first post.

add_filter('found_posts', 'myprefix_adjust_offset_pagination', 1, 2 );
function myprefix_adjust_offset_pagination($found_posts, $query) {

    //Define our offset again...
    $offset = 1;

    //Ensure we're modifying the right query object...
    if ( $query->is_home() ) {
        //Reduce WordPress's found_posts count by the offset... 
        return $found_posts - $offset;
    return $found_posts;

The final code snippet defines your offset one more time. Plus, it makes sure that pagination will work properly.

Once you’ve added the code snippets above, the latest post will now be removed from the WordPress post loop.

Method 2. Exclude Latest Post from WordPress Post Loop by Changing WordPress Theme Files

Another way to exclude the latest post from the WordPress post loop is by adding a single line of code to your WordPress theme files.

This achieves a similar result to the code above, but you will need to add it directly to the WordPress loop where you want it to display.

So, if you want to change the post loop sitewide, then you would add it to your index.php file.

Note: Adding this code to your WordPress files can cause issues with pagination on your website.

First, you’ll need to copy and paste the following code and add it to your WordPress loop.


This code is using the query parameter and telling the loop to only display 5 posts which follow the most recent post. The offset parameter stops the most recent post from displaying.

It will go directly above your WordPress post loop, so it will look similar to the code snippet below.

if ( have_posts() ) :
while ( have_posts() ) : the_post(); 

Once you’ve customized and saved the file, you need to upload it to your theme directory in your WordPress hosting account.

To do this, you can use an FTP client, or the file manager option in your WordPress hosting control panel.

If you haven’t used FTP before, then you might want to check out our guide on how to use FTP to upload files to WordPress.

After the code is added, the latest WordPress post will be excluded from the WordPress post loop and won’t show up on your blog page.

We hope this article helped you learn how to exclude the latest post from the WordPress loop. You may also want to see our guide on how to choose the best domain name registrar and our expert picks on the best GoDaddy alternatives.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.