Listing only child categories in list on category page?
-
Argh, I’ve just spent the last several hours trying to figure this out. I’ve found a few things on the Codex, and on the forum, but nothing seems to work the way it should. I hope someone might be able to help?
Goal: When viewing a category page, if the category has children categories, list only the children categories for that category.
This shouldn’t be too difficult. From what I found on the site, the following line of code ought to list only the children categories for a particular category. Right?
<?php wp_list_cats('child_of='.$this_category->cat_ID); ?>
Except, it doesn’t work. At all. Or rather, it works if I hard code a category id, which I don’t want to do. So, I tried echoing just $this_category->cat_ID, didn’t work. Same for $this_category. Which leads me to believe that’s the issue. Alas, I’m not finding the answer anywhere on how to solve it.
And it wouldn’t address displaying that list only if the category has children, but that’s a bridge I’ll cross if I can get the other bit to work.
Further, a side problem to this that may, or may not be related, something ain’t right with the results loaded from the_category() On category.php, I am calling the_category(”) just outside the loop. It works fine until I have children categories in a category. When that happens, if I load “category” on my menu, the_category displays “category child”.
I’m puzzled and would appreciate assistance on this.
Thanks
- The topic ‘Listing only child categories in list on category page?’ is closed to new replies.