Skip to content

Instantly share code, notes, and snippets.

@electricbrick
Created June 26, 2014 18:32
Show Gist options
  • Save electricbrick/30955941e362f8f17248 to your computer and use it in GitHub Desktop.
Save electricbrick/30955941e362f8f17248 to your computer and use it in GitHub Desktop.
If current taxonomy has child and/or parent
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); // get current term
$parent = get_term($term->parent, get_query_var('taxonomy') ); // get parent term
$children = get_term_children($term->term_id, get_query_var('taxonomy')); // get children
if(($parent->term_id!="" && sizeof($children)>0)) {
// has parent and child
}elseif(($parent->term_id!="") && (sizeof($children)==0)) {
// has parent, no child
}elseif(($parent->term_id=="") && (sizeof($children)>0)) {
// no parent, has child
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment