Title: current-cat-ancestor class?
Last modified: August 20, 2016

---

# current-cat-ancestor class?

 *  Resolved [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/current-cat-ancestor-class/)
 * I am using the wp_nav_menu with a custom ‘fallback_cb’ for category menu and 
   sub menu which is great to just two levels.
 *     ```
       <!--
       main category menu
       -->
       <?php wp_nav_menu( array( 'container_class' => '','theme_location' => 'none','fallback_cb'=>'digimag_top_categories') ); ?>
   
       <?php wp_nav_menu( array( 'container_class' => '','theme_location' => 'none','fallback_cb'=>'digimag_child_categories') ); ?>
       <!--
       Sub Category Menu if any exist
       -->
       ```
   
 * For a magazine / news theme I need three levels like Sports > Football > “Premier
   League”
 * So I need the parent “Football” and the ancestor “Sports” both highlighted in
   the main category menu and the sub-category menus for “Premier League” or it’s
   children.
 * Anyone know the code or a tutorail to add a category ancestor class to wp_nav_menu?
 * David 🙁

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/current-cat-ancestor-class/#post-2109450)
 * Oh – this drives me nuts too. The lack of an ancestor class for categories is
   a real oversight, in my opinion. Not sure if this is exactly what you want but
   it might get you started: [http://pastebin.com/airB2wE7](http://pastebin.com/airB2wE7)
 *  Thread Starter [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/current-cat-ancestor-class/#post-2109570)
 * Hi Esmi,
    Many thanks for sharing, that example has done the ‘logic’ trick, I
   could not quite work out how many levels the example covered.
 * I might be wrong but it looks to only updates the class of the top level category,
   and we could have a multi level tree.
 * I worked code from the current category up through the levels, using the append
   code in the example.
    [http://pastebin.com/Dygt3GiD](http://pastebin.com/Dygt3GiD)
 * Here is a [multi-level (5) test](http://theme.digitalraindrops.net/category/cat-a/cat-b/cat-c/cat-d/cat-e/)“
   Cat A” to “Cat E”, ancestor, ancestor, ancestor, parent and active.
 * I have only updated the main category menu not the sub-menu yet!
 * Thanks
 * David

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘current-cat-ancestor class?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/current-cat-ancestor-class/#post-2109570)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
