Last active
December 28, 2015 01:48
-
-
Save amdrew/7422708 to your computer and use it in GitHub Desktop.
Add download categories from Easy Digital Downloads to the post_class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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