Last active
September 5, 2024 01:44
-
-
Save amdrew/7422861 to your computer and use it in GitHub Desktop.
Add download categories to the class list of the EDD shortcode
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_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