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
Follow WPBeginner on YouTube
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 lovers 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 »
  • space

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

  • Sabi Maharjan

    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

      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.

  • Pastor Wynn

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

  • Gu-ens

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

  • Jim

    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.

  • Amin

    Thank you so much man! This helped a lot!


  • Fernando

    Thanks a lot!! very usefull tip!

  • GangeshMatta


  • PabloCovarrubias

    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

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

  • Jon

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

  • Wordpwess

    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

    • Editorial Staff

      Yes, you can just select category_in parameter, and add your category ID.

  • Luka

    Thanks mate, you save my day :)

  • Khurram

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

    • Editorial Staff

      what error are you getting?

  • Ken

    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

      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.

  • Joffrey

    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

      Don’t really understand your question? Which screen?

      • Joffrey

        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

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

        • Joffrey

          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

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

  • Bilal Ahmed

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

  • Jeremy

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


    • Editorial Staff

      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.

  • dominik

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

  • Morning Copy

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