Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.