Skip to content

Instantly share code, notes, and snippets.

@mkormendy
Created October 19, 2014 22:38
Show Gist options
  • Save mkormendy/e01dfce8a63e78ebd66b to your computer and use it in GitHub Desktop.
Save mkormendy/e01dfce8a63e78ebd66b to your computer and use it in GitHub Desktop.
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(); ?>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment