Created
February 15, 2012 15:58
-
-
Save wpsmith/1836901 to your computer and use it in GitHub Desktop.
Trying to add "last-post" class to the 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
$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
could add say a last to every 4th post.
<div class="post<?php if (!((1+$wp_query->current_post) % 4)) echo ' last' ?>">