I have a custom taxonomy with two levels of terms.
- Parent term
- Child term
- Child term
- Parent term
- Child term
- Child term
- Parent term (no children)
I'm using a custom archive.php
template with some HTML that I only want to display on terms without child terms.
Here's what I've tried...
$taxonomy = 'custom_tax';
$term = get_queried_object();
$children = get_terms( $term->taxonomy, array( 'parent' => $term->term_id ) );
if(!$children) {
echo '<p>HTML only terms without child terms</p>';
}
This works if it's a Child term but not on a Parent term with no children!
Any help please?