Skip to content

Instantly share code, notes, and snippets.

@kisildev
Last active April 17, 2019 10:31
Show Gist options
  • Save kisildev/b4d36f943822c336af98c198b25c3827 to your computer and use it in GitHub Desktop.
Save kisildev/b4d36f943822c336af98c198b25c3827 to your computer and use it in GitHub Desktop.
Get Term name of current page. Get Parent Term name of current page.
//Curent Term
<?php $term = get_term_by( 'slug', get_query_var('term'), get_query_var('taxonomy') );
echo $term->name; ?>
//Curent + Parent term
<?php $term = get_term_by( 'slug', get_query_var('term'), get_query_var('taxonomy') );
$parent_term = get_term( $term->parent, get_query_var('taxonomy') );
echo $parent_term->name.' : '.$term->name; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment