Anybody have any ideas how to achieve this? This problem has been driving me nuts since Saturday 🙁
Hey, I’ve been speaking with this problem with a guy on another forum, and he has kindly offered the following code:
$category = $target; // electric boogaloo lift or whatever
$string = "";
while ($category) {
// put the category at the beginning of the string
// at the beginning this is just putting the target's name in
$string = name_of($category) + " " + $string;
// move up to the parent
$category = find_category_for($category->parent)
// $category will be null if not found, meaning we've hit the top
// otherwise, we'll loop and process the parent
}
Now this is what he suggests I need to do, but he doesn’t actually use WordPress so this is kind of “pseudocode”. If there’s anyone who can help me make this work, or any other process which will allow me to display the name of the parent category then the child category, that would be so amazing!! As I have been banging my head against a brick wall for like 4 days trying to solve this now!!
Thank you 🙂