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 want to display my categories to a post like a list. i have this (parent- and child-) categories:

- Sports
    - Football
    - Basketball
- Toys
    - Dolls
    - Lego
- Books

for example one post is archived to the categories "Sports", "Football", and "Books" i want to output the categories like this:

    <li><a href="#">Sports</a>
        <ul class="children">
             <li><a href="#">Football</a></li>
    <li><a href="#">Books</a></li>

…as you can see, the hierarchical order by parent->child is important!

thanks, Jochen

share|improve this question

Using wp_list_categories


Something like this should give you what you want

$args = array(
    'hierarchical' => true,
    'hide_empty' => 0,
    'title_li' => ''

share|improve this answer
unfortunately not… it gives me ALL the categories from the system (like using it in the sidebar). but i want to have just the categories displayed which are assigned to the shown post!!! like using "the_category" in single.php! i hope you know what i mean... – Jochen Schmidt Feb 25 '13 at 15:50

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.