WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a hierarchical custom taxonomy called taxon... In my taxonomy.php I am showing children of the current taxon, if you click one of those children you should be taken to a page showing all of that child taxon's products. Parent taxons never have products so its just a navigation structure.

    $term_id = $term->term_id; 
    $taxonomyName = "taxons";
    $term_taxons = get_term_children($term_id, $taxonomyName);
    if ($term_taxons != null) { ?>
                Show Child Taxons
            <?php } else { ?>
                SHOW PRODUCTS
            <?php } ?>

This does not work. I have tried running the it like if $term_taxons == null then do something else something else and that doesn't work either...

share|improve this question
up vote 0 down vote accepted
if ( ! isset($term_taxons->errors)) { ?>
   Show Child Taxons
<?php } else { ?>
<?php } ?>

get_term_children returns a WP_error on failure.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.