Created
June 26, 2014 18:32
-
-
Save tomfinitely/30955941e362f8f17248 to your computer and use it in GitHub Desktop.
If current taxonomy has child and/or parent
This file contains 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
$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