Exclude Latest Post in WordPress Custom Loop

Apr 21, 2024

When you build a website in WordPress, sometimes you may not want to show the latest post in a custom section.

For example, on a news website, the latest post is already shown in a big banner at the top. Now below that, you want to show more posts—but you don’t want to repeat the same latest post again.

In this article, you will learn a simple way to skip the latest post using a custom loop. We will use a small setting called offset in WP_Query to control this easily.

<?php
$args = array(
    'post_type'      => 'post',  // Change this to your custom post type if needed
    'posts_per_page' => 5,       // Adjust the number of posts to display
    'offset'         => 1,       // Skip the latest post
    'orderby'        => 'date',
    'order'          => 'DESC'
);

$query = new WP_Query($args);

if ($query->have_posts()) : 
    while ($query->have_posts()) : $query->the_post(); ?>
        <article>
            <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
            <?php the_excerpt(); ?>
        </article>
    <?php endwhile;
    wp_reset_postdata();
else :
    echo '<p>No posts found.</p>';
endif;
?>

How It Works