Created
March 30, 2011 02:46
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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