Return the name of the subcategory?
-
This has been driving me crazy for over a day now, hoping someone can help.
Scenario: I have a category established “portfolio”, and then 4 sub-categories as children of this.
I have multiple posts with the “portfolio” category checked, as well as the subcategory checked (type of work).
I have a custom page template where I am pulling all “posts” from the parent category and displaying them. Everything works fine. What I need to do is pull the “subcategory” name as well for each post so I can display it in the HTML. For instance, one subcategory might be “web design”. On that particular post, the parent category “portfolio” is checked, as well as “web design”. I need to somehow grab the name of the subcategory and display it.
I’ve tried numerous things, and one worked at first (forget what code I used) where it was pulling the 2nd value of the category array. The problem is WP lists them alphabetically so it didn’t work for all categories.
I’ve tried messing with ‘child_of=3’ where 3 is the parent category name, but I simply can’t find the right wording to get it working. Any ideas?
- The topic ‘Return the name of the subcategory?’ is closed to new replies.