DPS, Add Category Classes

 * Display Posts Shortcode, add category classes 
 * @link https://displayposts.com/2019/01/03/add-category-classes/
function be_dps_add_category_classes( $classes ) {
  $categories = get_the_terms( get_the_ID(), 'category' );
  if( ! empty( $categories ) && ! is_wp_error( $categories ) ) {
    foreach( $categories as $category ) {
      $classes[] = 'cat-' . $category->slug;
  return $classes;
add_filter( 'display_posts_shortcode_post_class', 'be_dps_add_category_classes' );

For more information, see this support ticket

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