Title: Adding css classes to menu items not working
Last modified: August 20, 2016

---

# Adding css classes to menu items not working

 *  Resolved [cykeltomte](https://wordpress.org/support/users/cykeltomte/)
 * (@cykeltomte)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/adding-css-classes-to-menu-items-not-working/)
 * I’m trying to add specific custom classes to items in my menu by adding the css
   classes through the wordpress dashboard, but I can’t seem to get it to work. 
   I have added the class .test to style.css, but when applying the class to a menu
   item through wordpress dashboard no changes can be seen. The menu can be seen
   here: [http://mediastudent.ei.hv.se/~jeau0002/mobil/](http://mediastudent.ei.hv.se/~jeau0002/mobil/)
 * Am I missing something? I use bones_main_nav(); to call the menu, if it has something
   to do with it.
 * _[ Please do not bump, it’s [not permitted here](http://codex.wordpress.org/Forum_Welcome#No_Bumping).]_

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

 *  Thread Starter [cykeltomte](https://wordpress.org/support/users/cykeltomte/)
 * (@cykeltomte)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/adding-css-classes-to-menu-items-not-working/#post-2917909)
 * Solved it by adding this code to functions.php.
 *     ```
       add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
       function special_nav_class($classes, $item){
       	$title = strtolower($item->title);
       	$classes[] = $title;
       	return $classes;
       }
       ```
   
 * Not exactly what i had in mind, but it actually works better as it automatically
   adds the title of the menu item as a class.
 *  [tarik916](https://wordpress.org/support/users/tarik916/)
 * (@tarik916)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/adding-css-classes-to-menu-items-not-working/#post-2918083)
 * Thanks! This was helpful! I added $title = str_replace(” “,”_”, $title); below
   the first lowercase command in order to better format the classes.
 * Instead of how.can.we.help, it’s how_can_we_help.

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

The topic ‘Adding css classes to menu items not working’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [tarik916](https://wordpress.org/support/users/tarik916/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/adding-css-classes-to-menu-items-not-working/#post-2918083)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
