Print child category name, or change category order
-
Hello people…
So I’m making a list of posts only related to a certain category (a parent category)
In front of that list I want the child category name to be displayed.
Example:
I have a parent category names “Cars”
And the child categories are “Acura” and lets say “Honda”Now, I write a post and add the “Cars” parent category and “Acura” as the child category to the same post
I write another post and add “Cars” and the child category “Honda”.When I go to list of posts in the administration the categories are listed alphabetically.
So post A has categories: Acura, Cars
Post B has categories: Cars, HondaSo I make a list of posts looking like this
CATEGORY – TITLEI use:
$category = get_the_category();
echo $category[0]->cat_name;to display the first category only. (or inserting 1 and getting the second category)
Because they are sorted alphabetically the first result is Acura – Title
the second result is “Cars – Title” and not “Honda – Title”Anybody has a brilliant hack to sort it so the PARENT category is always displayed BEFORE the child category?
Thanks a bunch!
- The topic ‘Print child category name, or change category order’ is closed to new replies.