If Term is Parent Condition

Check if the current term is a parent and allow for different formatting based on conditions.

Term query

$term = get_queried_object();
$is_parent = $term->parent == 0 ? true : false;

Condition

if($is_parent) {  
// true 
} else {
// false 
}

Source.

Leave a Reply

Posted in php
katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.