Skip to content

Instantly share code, notes, and snippets.

@amdrew
Last active December 28, 2015 01:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amdrew/7422861 to your computer and use it in GitHub Desktop.
Save amdrew/7422861 to your computer and use it in GitHub Desktop.
Add download categories to the class list of the EDD shortcode
<?php
function my_child_theme_edd_post_classes() {
// get the terms from our 'download_category' taxonomy
$terms = get_the_terms( get_the_ID(), 'download_category' );
// keep our original edd_download class
$classes = array( 'edd_download' );
if ( $terms && ! is_wp_error( $terms ) ) {
// add each term slug to our classes array
foreach ( $terms as $term ) {
$classes[] = $term->slug;
}
}
// return a string of classes separated by space
return implode( ' ', $classes );
}
add_filter( 'edd_download_class', 'my_child_theme_edd_post_classes' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment