WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a loop that I would like to Offset by 1 so the most recent post is not displayed, and another loop where I only want 1 item which would be the most recent post.

These are the loops I tried: for both:

Offset Loop: <?php query_posts('offset=1'); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

and Most Recent Post Loop: <?php query_posts('posts_per_page=1'); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

The page doesnt load for me when I tried this, any ideas?

share|improve this question
up vote 1 down vote accepted

Neither of those are complete loops. That is, in both you have the start of an if but not the end of it, and the start of a while loop, but no the end of it. Also, you shouldn't be using query_posts either, as it over writes the main query and is rarely the right function for pulling posts. get_posts would be better.

I would do this, using one as an example:

<?php $r = get_posts('offset=1'); 
    if ( !empty($r) ) : 
        foreach  ( $r as $post ) : 
            // stuff
    endif; ?>

That should solve your problem with the page not loading.

What you are doing can be done with a single loop though, since get_posts without the offset will pull everything. You just need to take the first element as the recent post and loop through the rest.

share|improve this answer
thanks for the help! – Joe Bobby Nov 13 '12 at 5:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.