Simple post counter

Someone in our WPSerbia FB Page asked about different styles for first post in the loop, so this is the snippet for that.

 

<?php

if (have_posts()) : $counter = 1;
	while (have_posts()) : the_post();
		if( $counter == 1 ) { ?>

			/* First post */

		<? } elseif( $counter == 2 ) { ?>

			/* Second post */

		<? } else { ?>

			/* ...and all the rest */

		<?php }

		$counter++;

	endwhile;
endif;

?>

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.