How to modify default “sub-menu” class for child menu in WordPress

How to modify default “sub-menu” class for child menu in WordPress

Sometime we are needed to modify the default “sub-menu” class for the child menu in wordpress. There is no direct way you can do that but this can be done by placing a sample code in your functions.php like below:

function change_submenu_class($menu) {  
  $menu = preg_replace('/ class="sub-menu"/','/ class="submenu" /',$menu);  
  return $menu;  
}  
add_filter('wp_nav_menu','change_submenu_class'); 

Leave a Comment