DPS – Add class to current post

Using Display Posts Shortcode, if the current post is included in a listing, this snippet adds a class of “current” to it.

<?php
/**
* Display Posts Shortcode - "current" class on current post
*
*/
function be_dps_current_class( $classes ) {
if( get_the_ID() == get_queried_object_id() )
$classes[] = 'current';
return $classes;
}
add_filter( 'display_posts_shortcode_post_class', 'be_dps_current_class' );
view raw functions.php hosted with ❤ by GitHub

Display Posts Shortcode