Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@amdrew
Last active December 28, 2015 01:48
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 amdrew/7422708 to your computer and use it in GitHub Desktop.
Save amdrew/7422708 to your computer and use it in GitHub Desktop.
Add download categories from Easy Digital Downloads to the post_class
<?php
function my_child_theme_post_classes( $classes ) {
// get the terms from our 'download_category' taxonomy
$terms = get_the_terms( get_the_ID(), 'download_category' );
if ( $terms && ! is_wp_error( $terms ) ) {
// add each term slug to our classes array
foreach ( $terms as $term ) {
$classes[] = $term->slug;
}
}
return $classes;
}
add_filter( 'post_class', 'my_child_theme_post_classes' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment