Don't show top level taxonomy
-
I am using the following code to display the parent taxonomy term of the current term on the post. What I would like to do is not show the parent term if it is the top level term.
The reason why i want this is because I am using zip codes and cities, ideally it will show zip, city, state – but when there is no zip present and just the city is available it shows like this city, top level term, state
any ideas how to not show the top level term?
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $parent = get_term($term->parent, get_query_var('taxonomy') ); echo $parent->name; ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Don't show top level taxonomy’ is closed to new replies.