I hope i can explain this right , what im trying to do is use the default word press loop to show all my posts etc.. but for the first post I would like it to be styled completely different depending on what parent category it was published in, so there would be a lot going on in that first post.

Right now I'm some what achieving this by using 2 loops that both pull from the default, the first loop is my "new / Featured" post area and is set to posts_per_page=1 , then the second loop is your standard loop, but the issue I'm having is obviously it shows duplicate posts, now i tried offset=1 on the second loop but then my pagination does not work, any help or direction would be awesome, I know its a lot sorry. below is my code for both loops and a link to my testing site thanks!

1st (new / featured) loop :

<?php $custom_query = new WP_Query('posts_per_page=1'); 
while($custom_query->have_posts()) : $custom_query->the_post(); ?>
$parent_cat = array();
$post_cats = get_the_category($post->ID);
foreach( $post_cats as $post_cat ) {
if( $post_cat->parent ) $parent_cat[] = get_category( $post_cat->parent )->slug;


<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>
<?php } else { ?>

2nd (Standard) loop:

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>


<?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
<?php endif; ?>

Here is a link to the dev site were you can see what im talking about http://themes.thefragilemachine.com/gone/

thanks for any help!

3 Answers 3


one loop with a conditional statement to catch the first post should work; example:

<?php if( $wp_query->current_post == 0 && !is_paged() ) : ?>
/*the output of the first post*?
<?php else : ?>
/*the output of all other posts*/
<?php endif; ?>
  • Also check if is_archive() or !is_singular() to make sure the page does not have a single post. Don't know if is_paged() has same effect. Oct 26, 2011 at 16:57
  • this seems to be working but it is only showing 1 post, and no excerpt , themes.thefragilemachine.com/gone , I did noticed I do have is_paged() Oct 26, 2011 at 17:11

Just add a variable that will work just once with PHP like this for example:

<?php $custom_query = new WP_Query('posts_per_page=1'); 
$i = 0; while($custom_query->have_posts()) : $custom_query->the_post(); ?>

<?php if($i==0){ 

// do - echo whatever you want 


} else { 

// rest of the posts

} ?>  

<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>

Just check the current_post value

if(0 == $custom_query->current_post){ /**is the first post**/ }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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