Title: adding custom/current class support menu items
Last modified: August 30, 2016

---

# adding custom/current class support menu items

 *  [dmcleod87](https://wordpress.org/support/users/dmcleod87/)
 * (@dmcleod87)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/adding-customcurrent-class-support-menu-items/)
 * hi all,
 * i am editing a custom made theme for a client that was built by another developer.
 * i’m trying to add custom classes via the Menu page but don’t think the theme 
   has built in support. i can see the class=”” in the HTML with firebug, but it
   doesn’t appear. i also noticed there is no current class or parent class for 
   drop down menus as seen in other themes.
 * below is the code from header.php and here is a link to the live site – [http://www.epilase.com.au/](http://www.epilase.com.au/)
 *     ```
       <div class="collapse navbar-collapse">
                             <ul class="nav navbar-nav">
                           <?php 	
   
                           $current_page =  $wp_query->queried_object->post_name;
   
                           $menu_name = 'primary-menu';
                           $locations = get_nav_menu_locations();
   
                           if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) )
                               $menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
   
                           $args = array(
                           'order'                  => 'ASC',
                           'orderby'                => 'menu_order',
                           'post_type'              => 'nav_menu_item',
                           'post_status'            => 'publish',
                           'output'                 => ARRAY_A,
                           'output_key'             => 'menu_order',
                           'nopaging'               => true,
                           'update_post_term_cache' => false);
   
                           $menu_items = wp_get_nav_menu_items($menu->term_id,$args);
   
                           $current_page =  "http://".$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
   
                           $count = 1;
   
                           $menus = array();
                           $sub_menus = array();
   
                           foreach($menu_items AS $menu)
                           {
                               if($menu->menu_item_parent == 0)
                                   $menus[$menu->ID] = $menu;
                               else
                                   $sub_menus[$menu->menu_item_parent][$menu->ID] = $menu;
                           }
   
                           $num_menu = count($menu_items);
                           foreach((array)$menus AS $key => $menu)
                           {
       						$class = "";
       						$extra = "";
   
                               if(count($sub_menus[$key]) > 0)
                               {
   
       							$class = "dropdown";
       							$extra = 'class="dropdown-toggle" data-toggle="dropdown"';
   
       							?>
       							<li class="<?= $class; ?>"><a <?= $extra; ?> href="#"><?= strtoupper($menu->title); ?></a>
       							<ul class="dropdown-menu">
       							<?
   
                                   $count = 0;
   
                                   foreach($sub_menus[$key] AS $sub_menu)
                                   {
                                       ?><li><a href="<?= $sub_menu->url; ?>"><?= strtoupper($sub_menu->title); ?></a></li><?
   
                                       $count++;
                                   }		
   
                                   ?></ul><?
                               }
       						else
       						{
       							?>
       							<li class="<?= $class; ?><?= ($current_page == $menu->url) ? 'active' : ""; ?>"><a <?= $extra; ?> href="<?= $menu->url; ?>"><?= strtoupper($menu->title); ?></a>
       							</li>
       							<?
       						}
                           }
                           ?>  
   
                             </ul>
   
                           </div><!-- /.navbar-collapse -->
       ```
   
 * any help would be much appreciated!
 * thanks

The topic ‘adding custom/current class support menu items’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [dmcleod87](https://wordpress.org/support/users/dmcleod87/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/adding-customcurrent-class-support-menu-items/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
