Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created February 9, 2014 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/8893384 to your computer and use it in GitHub Desktop.
Save billerickson/8893384 to your computer and use it in GitHub Desktop.
Add category as class to display posts shortcode
/**
* Add category as class to display posts shortcode
*
*/
function be_dps_category_class( $classes, $post ) {
$categories = get_the_terms( $post->ID, 'category' );
foreach( $categories as $category )
$classes[] = 'cat-' . $category->slug;
return $classes;
}
add_filter( 'display_posts_shortcode_post_class', 'be_dps_category_class', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment