List only subcategories
Following scenario: I have one category that has several subcategories (there might be added more subcategories over time). Now, whenever one of the following is displayed, I want the usual “categories” list in the sidebar to be replaced with a list of all these subcategories (and no other categories):
– a post that is within one of these subcategories
– lists of all posts within one of these subcategories
So, I assume that I somehow have to get the category of the current post being displayed (or the category of the category-page being displayed) – then, I have to check whether it has a parent category, and if so, whether this parent-category is the category in question. Then, I’d use something like wp_list_categories(‘child_of=3’)
I do not manage to
a) get the category of the post being displayed currently OUTSIDE of the loop
b) get the category of the category list, if such a list is displayed
c) check what is the parent-category of the category I got in step a or b.
Can someone help?
- The topic ‘List only subcategories’ is closed to new replies.