Last active
June 30, 2020 12:12
-
-
Save SuryawanshiPrajakta/97356d74bf390f422c7ca6b61405144b to your computer and use it in GitHub Desktop.
Display only parent categories in Taxonomy Badge
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
Add the following code in active child theme's functions.php | |
add_filter( 'uael_posts_tax_filter', function( $terms ) { | |
$parent_terms = array(); | |
$terms = wp_get_post_terms( get_the_ID(), 'category' ); | |
foreach( $terms as $term ){ | |
if( $term->parent == 0 ){ | |
array_push( $parent_terms, $term ); | |
} | |
} | |
return $parent_terms; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment