Created
April 2, 2016 05:13
-
-
Save Creativenauts/054a74731d8f035883b4d29bc176c89c to your computer and use it in GitHub Desktop.
Easy Digital Downloads - Get Parent Category For a Download (Exclude Categories as well!)
This file contains 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
function get_edd_parent_category() { | |
global $post; | |
$terms = wp_get_post_terms( | |
$post->ID, | |
'download_category', | |
array( | |
'parent' => 0 | |
) | |
); | |
// Exclude Categories - Perfect For Sites That Offer Top Level | |
// Categories For Displaying Product Grids | |
$terms = wp_list_filter($terms, array('slug'=>'popular'),'NOT'); | |
$terms = wp_list_filter($terms, array('slug'=>'free'),'NOT'); | |
$terms = wp_list_filter($terms, array('slug'=>'bundles'),'NOT'); | |
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ | |
foreach ( $terms as $term ) { | |
echo $term->name; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment