Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Display Child Taxonomy on Parent Taxonomy’s Archive Page

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Display Child Taxonomy on Parent Taxonomy’s Archive Page

In the past we have shown you how to display subcategories on category pages in WordPress. Recently while working with Custom Taxonomies, we found a need to display child-taxonomies on parent-taxonomies archive page. After doing a bit of research, we didn’t find a single tutorial covering this issue. In this article, we will show you how to display a list of child taxonomies on taxonomies pages.

Open up your custom taxonomy template file which may look like: taxonomy-{taxonomyname}.php and paste the following code where ever you want to display the list:

$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 
if ($term->parent == 0) {  
&title_li=&child_of=' . $term->term_id);
} else {
&title_li=&child_of=' . $term->parent);	

Don’t forget to replace YOUR-TAXONOMY-NAME with the name of your taxonomy.

Final Result:

List of Taxonomies


We are using get_term_by to query the information of the current taxonomy by slug. For example if your taxonomy is called topics and you are on a page /topics/nutrition/ then $term variable will pull all the data related to the specific term page that you are on.

In the project we were working on, the topics taxonomy was hierarchical just like categories. So we decided to run a conditional using $term->parent variable. This variable outputs the ID of the parent taxonomy. So if you are on the taxonomy nutrition which is the parent taxonomy, then $term->parent will echo 0. This is why we said if $term->parent == 0 then use wp_list_categories() function to display terms from our custom taxonomy that are child_of the term which page you are on. We accomplished this by using $term->term_id as the child_of variable.

Now if you go to the child taxonomy page, it would have been blank because the $term->parent would no longer equals to 0. On a child taxonomy page, $term->parent outputs the ID of the parent category. So we ran an else statement using the same wp_list_categories() function except we changed $term->term_id to $term->parent.

There you have it. We hope that this helps everyone who was looking for a solution.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Niek says:

    I know this is an old post but for some reason this code does not work anymore. It works fine listing the child terms on the parent taxonomy term, but on the child term archive page it just says ‘no categories’.

    Maybe you have a fix for this?

    • Shaw says:

      Yeah, It isn’t working for me either. Did you find a fix for this yet?

      • Mark says:

        try this one its only shown subcategories in the main category
        ‘taxonomy’ => ‘YOUR-TAXONOY-SLUG’,
        ‘title_li’ => ”,

      • Mark says:

        $args = array(
        ‘parent’ => get_queried_object_id(),
        ‘taxonomy’ => ‘YOUR TAXONOMY NAME’,
        ‘title_li’ => ”,

  2. Zulya says:

    Hello. Thank you for the code. It works.
    But I have a question. How can I hide “title” when hovering the custom taxonomy links. At the moment, the description of each custom taxonomy is displayed in hovering title. Thank you.

  3. Susan Clifton says:

    I’m using the plugin Taxonomy Images so I would like to include that thumbnail in this list. This is my structure:
    Custom post type= Artwork
    hierarchical taxonomy= Artist Name

    I’m looking for each artist name to up with the thumbnail as a grid list to view artwork.
    I created a taxonomy template for the single artist page, no problem but can’t figure out how to do a list of artists. This solution almost works for me. But I’m getting each artist multiple times in this list.

    Hint…Hint ;)

    • Editorial Staff says:

      Hey Susan,

      Not sure why you are getting each artist multiple times. As for Taxonomy Images, Michael Fields have a bunch of queries on the plugins page.

  4. Jake says:

    Almost exactly what I was looking for. I however have one problem: when my Taxonomy has no children I get a single list item that says “No Categories”. What should I do to just display nothing if there are no children?

    Much appreciated!

  5. James says:

    Had been googling for a while for a solution like this. Cheers

  6. Rasha says:

    Can it show thumbnail also for child terms ??

  7. Rottenpeach_com says:

    @syedbalkhi I confused Taxonomy with Taxidermy…#TheAwkwardMoment

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.