Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Exclude Latest Post from the WordPress Post Loop

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Exclude Latest Post from the WordPress Post Loop

Excluding latest posts from the loop and/or offset posts in the loop is one of the things that comes in handy when editing or designing themes. In this article we will show you how you can use the offset parameter in wp_query function to exclude latest posts from the WordPress post loop.

First you will need to find the loop that you are working with. Then you will need to add the following parameter:


This query is telling the loop to only display 5 posts which follow the most recent post (1). The important part in this code is “offset” and this magic word is doing the whole thing.

Your loop code should look like:

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

This should be it. If you have any questions feel free to ask via comments.

Source: WP Codex

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Praveen says:

    Thanks, Good job, Good Solution

  2. Matt says:

    Beauty post! Simple, clear, and VERY handy. Cheers to you!

  3. Dimarj says:

    ;-) Thanks for this. :-) :-(

  4. BGH_ says:

    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:

  5. space says:

    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 ? .

    • Rickie Anand says:

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

  6. Sabi Maharjan says:

    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 ?

    • WPBeginner Support says:

      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.

  7. Pastor Wynn says:

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

  8. Gu-ens says:

    Thanks a lot.
    the ‘post__not_in’ option does not work in wordpress 3.5

  9. Jim says:

    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.

  10. Amin says:

    Thank you so much man! This helped a lot!


  11. Fernando says:

    Thanks a lot!! very usefull tip!

  12. GangeshMatta says:


  13. PabloCovarrubias says:

    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!!


    • space says:

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

      • Kev Bowman says:

        Did you ever find a solution for this?

        • de hams says:

          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()

  14. Jon says:

    Thanks so much for this! I couldn’t figure it out at all but this worked perfectly.

  15. Wordpwess says:

    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

  16. Luka says:

    Thanks mate, you save my day :)

  17. Khurram says:

    “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. :(

  18. Ken says:

    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!

    • Editorial Staff says:

      You can exclude all posts from the category “postcast” from your loop if you want. But there is no simple way of excluding just the latest post.

  19. Joffrey says:

    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!

    • Editorial Staff says:

      Don’t really understand your question? Which screen?

      • Joffrey says:

        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!

        • Editorial Staff says:

          You can add offset=1 in the query to skip the first post.

        • Joffrey says:

          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 :)

        • Editorial Staff says:

          Email us the live link to the site, so we can see exactly whats going on. Use the contact form for email.

  20. Bilal Ahmed says:

    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 :)

  21. Jeremy says:

    Where exactly do you put this code to remove al posts but the sticky on the main page.


    • Editorial Staff says:

      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.

  22. dominik says:

    Thanks, it was exactly what I was looking for! Thanks for any other hints.

  23. Morning Copy says:

    Thanks for this. Nice solution for magazine-style layouts.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.