Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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.