fromi’m using wp_list_categories to get an unordered list with headlines (on single.php inside the post-loop):
<ul><?php wp_list_categories('title_li=0');?></ul>
the thing is: i want to use it in the same way as “the_category” which means that i want to display ONLY the current categories of the post!
by now, it dsiplays ALL the categories and subcategories from the system (like it does using it in the sidebar and which makes sense there).
is there a way to do it?
thanks,
Jochen
EDIT: actual output (category list with ALL categories from the whole system:
<ul> <li class="cat-item cat-item-10"><a href="#">Cat1</a>
<ul class='children'>
<li class="cat-item cat-item-18"><a href="#">Subcat1</a>
</li>
<li class="cat-item cat-item-13"><a href="#">Subcat2</a>
</li>
</ul>
</li>
<li class="cat-item cat-item-1 current-cat"><a href="#">Cat2</a>
<ul class='children'>
<li class="cat-item cat-item-12"><a href="#">Subcat1</a>
</li>
</ul>
</li>
<li class="cat-item cat-item-9"><a href="#">Cat3</a>
<ul class='children'>
<li class="cat-item cat-item-20"><a href="#">Subcat1</a>
</li>
<li class="cat-item cat-item-19"><a href="#">Subcat2</a>
</li>
</ul>
</li>
<li class="cat-item cat-item-11"><a href="#">Cat4</a>
<ul class='children'>
<li class="cat-item cat-item-15"><a href="#">Subcat1</a>
</li>
<li class="cat-item cat-item-14"><a href="#">Subcat2</a>
</li>
</ul>
</li>
</ul>
this is good so far! but the expected output i want to get is the same list as above but with just the CATEGORIES FROM THE DISPLAYED POST (not every category form the system)… i think “current” was the wrong word (sorry, i’m not a native speaker)!!
for example i open a post (single.php) with the attached category “Cat1” i want to have an output like this:
<ul> <li class="cat-item cat-item-10"><a href="#">Cat1</a>
<ul class='children'>
<li class="cat-item cat-item-18"><a href="#">Subcat1</a>
</li>
<li class="cat-item cat-item-13"><a href="#">Subcat2</a>
</li>
</ul>
</ul>
i hope you can help! thanks…
Have you tried
'current_category' => 1,
?e.g.:
There’s a chance it will still output all of them, but with a CSS class on the current categories, at which point you hide them all with CSS and unhide the ones with that class.
Always refer to the codex entry:
http://codex.wordpress.org/Template_Tags/wp_list_categories