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.

* 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

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk