Skip to content

Instantly share code, notes, and snippets.

@Creativenauts
Created April 2, 2016 05:13
Show Gist options
  • Save Creativenauts/054a74731d8f035883b4d29bc176c89c to your computer and use it in GitHub Desktop.
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!)
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