Created
December 15, 2011 11:47
-
-
Save davemac/1480832 to your computer and use it in GitHub Desktop.
WordPress get the category parent slug and include in body_class - works in posts with multiple cats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if (is_single() || is_category()) { | |
$category = get_the_category(); | |
$nice_name=array(); | |
foreach($category as $c) | |
{ | |
$parent = $c->category_parent; | |
$parent_cat =get_category($parent); | |
$nice_name[]= $parent_cat->category_nicename; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment