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