Beginner's Guide for WordPress / Start your WordPress Blog in minutes

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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

39 CommentsLeave a Reply

  1. Hey guys, thanks for this article! I want to implement this, but whenever I try I’ve got an strange problem: entries would look like exactly like the frontpage, showing a list of recent post rather than the post itself. My code is slightly different, since is a SMTheme. Any help will be much appreciated. PS: Sorry for posting twice, but the code has printed wrong. Here you go:

  2. Solution is work fine, Thanks. but pagination broke after applying this code, I have tried but not able to work with correct pagination. Any solution to pagination ? .

    • apply class to the li as per the number of page and a counter & give style to p1c1 as display:none;

  3. I have used two plugins. One is “Recent facebook post” to show recent posts in wprdpress and “Facebook publish page” to publish my wordpress posts in facebook . Now I want exclude the recent post of the facebook that was already posted from my wordpress posts .

    How can I do it ?

    • For that your plugin posting content from your Facebook page should have a check to see if a post was already published from WordPress to Facebook. We do not recommend users to directly edit plugin files. However, if you are comfortable editing php files then you can fork the plugin as a new plugin and then add the code to accomplish this.


  4. Thanks for the great tip. I had spent hours trying to figure this out, and you made it so simple!

  5. Hmm, when i tried this code on a category page loop, it couldn’t keep the posts for only that category, instead it acted as if it was the front page loop and displayed all posts.

  6. hello, i just have one question, when i do this, pagination doesen0t work anymore, how can i fix this?

    thanks, other than that, it works perfectly!!


    • Yes, pagination not working. you have found any working solution for pagination, I am still searching .. :(

        • pagination do not work on index page most so we can make out own ajax pagination call and mostly query_posts() works for pagination rather then WP_Query()

  7. Is there a way to offset a post from one cat?

    E.g I want to show all posts apart from the LATEST post of category x

  8. “query_posts(‘posts_per_page=6&offset=1’);” this is not worked for me , while i am using the WP-PageNavi plugin for page navigation. :(

  9. Thanks for the info. Worked well :) Though, I’m encountering another issue for another site I’m currently doing. Is there a way to exclude from the loop only the latest post of a particular category?

    Thing is, I’ve a blog that publishes podcasts. The front page highlights the most recent podcast – posts are published under category: Podcast – via its own styling. At the same time, the front page also shows the last 5 most recent posts, of which may include posts under the category “podcast”. I just don’t want to show in the loop the most recent post published under “Podcast” simply because it’s already featured with it’s own styling. Hope you can help me out. thanks!

  10. Thanks for the tip!
    But I was wondering if there is also a way to exclude the post that is currently showed on screen.

    If yes, can you tell me how to do this?

    Thanks in advance!

      • One of my pages displays first of all the latest or current post the user is viewing.

        The current post is called by the loop.

        Below this post I want to display the excerpts of other previous posts without the current post displayed in this list.

        The previous post-excerpts are called by query_posts:

        while($previousPosts->have_posts()) : $previousPosts->the_post();

        As you can see I call 3 posts(excerpts) from category 5 which displays three posts from category News. This seems ok but within these 3 post-excerpts, the current post which is called by the loop is also in this list.
        Do you know a way to exclude the current post within this list?

        Thanks again!

        • Thanks again for the quick response!
          However, I did try the offset=1 in the query, only thing is that when you press an older post, you get to see the older post in the main loop, within the list excerpts the latest post is excluded, but the older post which is now the current post is still in the excerpts list.

          Any idea how to exclude not the latest but the current post?

          Thanks so far already :)

  11. Thank you so much for this piece as i was looking for a way to exclude 4 latest posts form my home page and i got answer by this articles and i have replaced (query_posts(‘posts_per_page=6&offset=1’);) by query_posts(‘posts_per_page=6&offset=3’); and its done :)

    • That is a multi-step process. First you would need to have a custom page template. Second you would need to create that custom page, your front page. Then you would run a query on that custom template showing only sticky posts.


Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.