mkormendy
10/19/2014 - 10:38 PM

Inserting a class onto the element of the last post of a Wordpress loop.

Inserting a class onto the element of the last post of a Wordpress loop.

<?php /* The Loop */ ?>
<?php $post_counter = 0;
while ( have_posts() ) : the_post() ?>
	<?php $post_counter++; ?>
	<div id="post-<?php the_ID(); ?>" <?php if( $post_counter == count( $posts ) ) post_class('last-post'); else post_class(); ?>>