Skip to content

Instantly share code, notes, and snippets.

@jtsternberg
Forked from wpsmith/nothing.php
Created February 15, 2012 16:13
Show Gist options
  • Save jtsternberg/1836977 to your computer and use it in GitHub Desktop.
Save jtsternberg/1836977 to your computer and use it in GitHub Desktop.
Trying to add "last-post" class to the loop
$post_classes = get_post_class();
$odd_or_even = 'even';
$post_counter = 0;
$post_counter++;
$odd_or_even = ( 'odd' == $odd_or_even ) ? 'even' : 'odd';
$post_classes[] = ( $post_counter == count( $posts ) ) ? 'last-post' :$odd_or_even;
echo '<div class="' . implode( ' ', $post_classes ) . '">';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment