Skip to content

Instantly share code, notes, and snippets.

@jeremyboggs
Created March 30, 2011 02:46
Show Gist options
  • Save jeremyboggs/893765 to your computer and use it in GitHub Desktop.
Save jeremyboggs/893765 to your computer and use it in GitHub Desktop.
Adds a counter to check for the first post in a WP loop.
<?php $count = 0; ?>
<?php if( have_posts() ) : while( have_posts() ) : the_post(); ++$count; ?>
<div class="post">
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<?php if (($count == '1') && (!is_paged())): // If it's the first post on the first page. ?>
<?php if ( has_post_thumbnail() ) the_post_thumbnail(); ?>
<?php the_excerpt(); ?>
<?php else: // If it's any other post on any other page. ?>
<?php the_content(); ?>
<?php endif; ?>
</div>
<?php endwhile; endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment