Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 0 down vote accepted
if ( ! isset($term_taxons->errors)) { ?>
   Show Child Taxons
<?php } else { ?>
   SHOW PRODUCTS
<?php } ?>

get_term_children returns a WP_error on failure.

share|improve this answer
add comment

Your Answer

 
discard

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.