Skip to content

Instantly share code, notes, and snippets.

@shazdeh
Created January 6, 2014 21:39
Show Gist options
  • Save shazdeh/8290250 to your computer and use it in GitHub Desktop.
Save shazdeh/8290250 to your computer and use it in GitHub Desktop.
Highlight current post in the loop
<?php
function highlight_current_post( $classes ) {
global $post, $wp_query;
if( $post->ID == $wp_query->post->ID ) {
$classes[] = 'current-post';
}
return $classes;
}
add_filter( 'post_class', 'highlight_current_post' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment