How To Get Parent Category Slug of Current Post
You will need to use the ID value returned by $category[0]->category_parent and pass it through get_term(). Example: $category = get_the_category(); $category_parent_id = $category[0]->category_parent; if ( $category_parent_id != 0 ) { $category_parent = get_term( $category_parent_id, ‘category’ ); $css_slug = $category_parent->slug; } else { $css_slug = $category[0]->slug; }