I have a custom post-type 'videos' and on the first page I have the first video styled differently than the next videos on the page. Basically I show the first video in a large format, while the rest of the videos on the page are small.


On page 2, 3, etc of the video post-type, I do not want to have a large video on the top of the page, but rather follow my standard styling.

What would be the best way to do this?

Currently I am using rewrite rules to allow me a second template page for my 'paged' for the post-type. I would rather not use this approach anymore as it is more to maintain.

If I used a check like if_paged.. then I find that I have to replicate a ton of code on my template. Hoping there is a simple way to identify the first post in the loop, style that, and then continue... open to any ideas


2 Answers 2


In response to your comment, $wp_query->current_post in action. Note that it's zero-indexed:


if (have_posts()) :
while (have_posts()) : the_post();

        echo "this is the first post";
        echo "this is post number " . ($wp_query->current_post + 1);


  • Thank you, learned something new today! Love those kind of days
    – shawn
    Jun 4, 2011 at 23:54
  • thanks - a great way to get rid of that counter. imgo, this would still need to be combined with is_paged() get achieve the aim of the original question.
    – Michael
    Jun 5, 2011 at 9:59

i don't think there is anything easier than to use the is_paged() together with a counter;

before the loop: <?php $counter = 1; ?>

in the loop:

<?php if( $counter == 1  && !is_paged() ) : 
$counter++; ?>
/*code for the first post with large video*/
<?php else : ?>
/*code for all other posts*/
<?php endif; ?> 

the amount of duplicated code obviously depends on the existing structure of the loop.

  • 1
    or use the global $wp_query->current_post to check where you are in the loop.
    – Milo
    Jun 4, 2011 at 20:48
  • @Milo I have not seen this concept before. Do you have a snippet example of how this would work? While I understand Michael's snippet, I am always looking to learn new things.
    – shawn
    Jun 4, 2011 at 22:55
  • @shawn - I posted an example.
    – Milo
    Jun 4, 2011 at 23:47

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.