Last active
August 29, 2015 14:23
-
-
Save braginteractive/42ea24f852e15cd32025 to your computer and use it in GitHub Desktop.
Add class to the last WordPress post
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
/** | |
* Add 'last' class to last post | |
* Must be using <?php post_class(); ?> | |
*/ | |
function add_last_class($classes) { | |
global $wp_query; | |
if(($wp_query->current_post + 1) == $wp_query->post_count) | |
$classes[] = 'last'; | |
return $classes; | |
} | |
add_filter('post_class', 'add_last_class'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment