The question is simple.
Imagine that I have a post named ‘Single Post’ which is inside the category ‘sub-cat’ which is a child of ‘parent-cat’ which is a child of ‘super-cat’.
What I need to do is to display all the related categories within the post page in the following order:
super-cat > parent-cat > sub-cat > Single Post
This works correctly when the post is in just one category. But if it’s in multiple categories, or if the category parents are also selected â in your case, if the post is also in super-cat and parent-cat â then it displays those categories twice.
So this is probably not going to do it for you.
I suspect some of the breadcrumb type plugins might have solved this though.
you need to sort the categories first.
I hope this helped.
This should do the trick:
First we get categories for particular post, then we find last child and then with get_category_parents we get whole tree of its parents…
Here my working solution for that:
It echoes the string ready for the breadcrumb, and with a little modification yo can get the categories ordered as array.
Old question but top result on Google for me. I couldn’t quickly find a breadcrumb categorization, supporting multiple categories, so I created one and wrapped it in a
ul
for easy styling: