Title: Multiple Post Categories PLUS Parent Categories
Last modified: September 1, 2016

---

# Multiple Post Categories PLUS Parent Categories

 *  [Julie Kuehl](https://wordpress.org/support/users/juliekuehl/)
 * (@juliekuehl)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/multiple-post-categories-plus-parent-categories/)
 * I have a site where there are events that have categories attached to them. I
   want to be able to filter the events by the categories by using the slugs as 
   CSS classes. Problem is the filter is limited to top-level categories and events
   can have multiple categories attached to them.
 * For instance, the categories could look like this:
 * –Dance
    –Music —-Pop —-Rock –Theatre
 * What I’m aiming for is to be able to handle it if a user selected “Dance” and“
   Rock” and have the CSS classes of “category-dance”, “category-rock”, AND “category-
   music”.
 * The `post_class()` does fine for getting the multiple categories taken care of(
   showing “category-dance” and “category-rock”), but I’m struggling to figure out
   how to add the top-level parent category (“category-music”) to the list.
 * I’m sorry, but the site is currently in a dev environment and not publicly accessible.
   🙁
 * Do you have any suggestions that might help?

Viewing 1 replies (of 1 total)

 *  [ikaring](https://wordpress.org/support/users/ikaring/)
 * (@ikaring)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/multiple-post-categories-plus-parent-categories/#post-7704478)
 * Hi. Its not a solution but could be a hint, I hope.
 *     ```
       <?php
         $catobj = get_category_by_slug( 'rock' );// get category slug somehow
         $parent_id = $catobj->category_parent;
         if ( !empty($parent_id) ){// when parent category exists
           $parentname = get_the_category_by_ID( $parent_id );
           var_dump($parentobj);
         }
       ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Multiple Post Categories PLUS Parent Categories’ is closed to new replies.

## Tags

 * [categories](https://wordpress.org/support/topic-tag/categories/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [ikaring](https://wordpress.org/support/users/ikaring/)
 * Last activity: [9 years, 8 months ago](https://wordpress.org/support/topic/multiple-post-categories-plus-parent-categories/#post-7704478)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
