Ordering Categories by Grandparent
-
So first time poster, long time lurker.
So my categories look something like
Theme
-Subtheme
–CatsRegion
-Subregion
–NebraskaIn the loop I’m trying to get it to say “Cats in Nebraska.” So the category should be organized with the ‘Theme’ Categories first and the ‘Region’ Category second. I’ve been able to make it work but ONLY for parent and child. If the category is the grandchild of theme or region it doesn’t work anymore.
<?php $region = ''; $theme = ''; foreach((get_the_category()) as $category) { if ($category->category_parent == '12') { // author $region = $category->name; } elseif ($category->category_parent == '10') { // genre $theme = $category->name; } } if($region > ' ' && $theme > ' ') { echo "$region in $theme"; } ?>Does anyone know how I can get this working with the top level categories?
The topic ‘Ordering Categories by Grandparent’ is closed to new replies.