Display Subcategories of Different Parent Categories of the Same Post
-
By default, displaying categories for the current post, displays ALL categories alphabetically. I want to modify that to show subcategories of a particular parent category and subcategories of another particular parent category, separately. It’s not working for me at all.
Every tutorial that I find shows how to either display all posts of a category or all categories of a post. I hope this is making sense. To explain what I mean, my exact code and the rendered text is below.
Here are the categories and their IDs, so that you can see what I am doing in the code.
Counties = 1
Industries = 60
Examples = 81In the rendered text, “Hardy” is the county assigned to this example post and “Advertising” is the industry. “Example” should not even be displaying.
The Code:
<div class=”meta”>County: <?php the_category(‘child_of=1&exclude=81’) ?> | Industries: <?php the_category(‘child_of=60&exclude=81’) ?></div>The Text Rendered on the Page:
County: Advertisingchild_of=1&exclude=81Exampleschild_of=1&exclude=81Hardy | Industries: Advertisingchild_of=60&exclude=81Exampleschild_of=60&exclude=81Hardy
- The topic ‘Display Subcategories of Different Parent Categories of the Same Post’ is closed to new replies.