Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk3 min

How to Exclude the Latest Post From the WordPress Post Loop

Exclude the newest post by ID with post__not_in—using pre_get_posts for the main index, query arguments for a custom loop, or the Query Loop block’s controls.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To keep the newest post out of a WordPress post loop, exclude its post ID with post__not_in. For the main blog index, set that argument with pre_get_posts; for a separate PHP loop, pass it to WP_Query. In the block editor, use the Query Loop block’s exclusion controls. Avoid using offset to skip a post if pagination matters.

Exclude the newest post from the main blog index

Add a pre_get_posts callback to your theme or site plugin. The example below finds the most recently published post, then excludes its ID only from the front-end main home query:

function mysite_exclude_latest_post( $query ) {
    if ( is_admin() || ! $query->is_home() || ! $query->is_main_query() ) {
        return;
    }

    $latest_post = get_posts(
        array(
            'numberposts' => 1,
            'post_status' => 'publish',
            'orderby'     => 'date',
            'order'       => 'DESC',
        )
    );

    if ( ! empty( $latest_post ) ) {
        $query->set( 'post__not_in', array( $latest_post[0]->ID ) );
    }
}
add_action( 'pre_get_posts', 'mysite_exclude_latest_post' );

pre_get_posts runs after query variables are prepared and before the query executes. Use the passed $query object’s conditionals, as in the example, to limit the change to the intended query; broad changes can affect other loops in areas such as sidebars and footers. WordPress’s documentation also demonstrates excluding IDs on the home page with post__not_in: pre_get_posts.

Adjust what “latest” means

This sample selects the latest published post overall. If you mean the latest item in a particular post type, category, or other scope, make the ID lookup use that same scope. The separate get_posts() call performs its own retrieval query. If your application already has the ID, use it directly instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep an existing exclusion list

If another part of your code has already set post__not_in, merge the latest ID into that array rather than replacing the existing exclusions. Otherwise, the callback can unintentionally undo exclusions set elsewhere.

Exclude a post from a custom PHP loop

For a secondary loop in a template, pass the excluded ID in the WP_Query arguments:

$excluded_id = 123; // Replace with the ID determined by your site logic.
$loop = new WP_Query(
    array(
        'post_type'      => 'post',
        'posts_per_page' => 10,
        'post__not_in'   => array( $excluded_id ),
    )
);

Use the ID your site logic identifies as the latest post. WordPress documents post__not_in as the query argument for excluding post IDs: WP_Query. If you use get_posts() instead, its exclude argument provides the equivalent exclusion: get_posts().

Choose the right method for the loop

Loop you are changing Where to set the exclusion Pagination consideration
Main blog home query pre_get_posts callback, limited to the intended main query Exclude by ID rather than shifting results with offset.
Custom PHP query post__not_in in WP_Query, or exclude in get_posts() Keep the custom query’s page parameter and exclude by ID.
Block editor Query Loop Use the block’s post exclusion settings Use the block’s query controls rather than changing an unrelated PHP query.

Preserve pagination and avoid common traps

Do not use offset as a skip-the-first-post shortcut

An offset shifts results, but WordPress warns that it can override or ignore paged, breaking pagination. Excluding the specific post ID avoids that problem while leaving the query’s page setting in place. See the WP_Query documentation.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Account for static front pages

On a static front page, WordPress documents pagination with page rather than paged. The theme handbook also notes that static front pages are not intended to use the usual previous/next pagination functions: Pagination.

Sticky posts are not excluded automatically

ignore_sticky_posts controls whether sticky posts are moved to the top of results; it does not remove the newest post from the query. To omit a post entirely, exclude its ID with post__not_in.

Do not use query_posts() for this change

query_posts() replaces the main query. WordPress recommends modifying the main query with pre_get_posts, or using WP_Query or get_posts() for general post retrieval: query_posts().

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Exclude a post in the Query Loop block

If the loop is a Query Loop block in the block editor, configure exclusions in the block instead of adding PHP for a query it controls. The block’s query configuration supports excluding specific post IDs and excluding the current post: Query Loop block reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.