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

Is there a way that I can list all the terms within a custom taxonomy in an unordered list and wrap all child terms in another unordered list?

For example;

<ul class="menu">

    <li><a href="#">Parent 1</a></li>
        <a href="#">Parent 2</a>

        <ul class="sub-menu">

            <li><a href="#">Child of Parent 2</a></li>
            <li><a href="#">Child of Parent 2</a></li>
            <li><a href="#">Child of Parent 2</a></li>


    <li><a href="#">Parent 3</a></li>

share|improve this question
up vote 1 down vote accepted

You can take a look at the Wordpress function wp_list_categories(). If you want to display all the terms within a given custom taxonomy you can for example use:

$args = array(
  'taxonomy'     => 'my_custom_taxonomy_slug',
  'orderby'      => 'name',
  'hide_empty'   => 0,
  'title_li'     => '',
  'hierarchical' => 1,
  'walker'       => null,
<ul class="menu">
<?php wp_list_categories( $args ); ?>

If you need to adjust the html structure, you can use a custom walker that extends either Walker_Category or Walker.

You can read more about it here in the Codex:


share|improve this answer
I didn't even need to add a walker, child categories are already contained in a ul! Thanks for steering me in the right direction! – Dean Elliott Mar 27 '13 at 20:46
you're welcome, good luck with your project. – birgire Mar 27 '13 at 20:48

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.