How do I show child categories if in a parent category, and posts if in a child?
-
I was hoping to do all of this within the category.php template, with help from the functions.php if needed.
If my setup is:
Parent 1 --Child 1 --Child 2 Parent 2 --Child 3 --Child 4 Parent 3 --Child 5 --Child 6 ...and so on
I would like to be able to do this:
If I was viewing Parent 1 (or 2/3), it would show me Child 1 and Child 2. However, I don’t want to use wp_list_categories because for each Child, I would like to show a thumbnail (from a plugin function), the Child’s name, and the category description.
If I was viewing Child 1 (or 2/3/4/5/6), it would show me the latest 2 posts using the standard Loop.
I would like avoiding having to do this using hard-coded contitionals with the specific names of the categories, in case new ones will be added in the future.
Any assistance will be appreciated. Thank you!
- The topic ‘How do I show child categories if in a parent category, and posts if in a child?’ is closed to new replies.