6-yxga
Last Updated: February 25, 2016
·
14.57K
· riyadhalnur

Change WP default sub menu class

In WordPress, all sub-menus have the class 'sub-menu'. To change it to a custom class, add the following code in your functions.php file.

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

3 Responses
Add your response

17481

Perfect, congrats from Brazil. muito obrigado!

over 1 year ago ·
18082

thanks a lot! that worked....

over 1 year ago ·
18083

welcome :)

over 1 year ago ·