6-yxga
Last Updated: February 25, 2016
·
10.68K
· riyadhalnur
10309058 10152457564452360 4465802230248535815 n

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');  
Say Thanks
Respond

3 Responses
Add your response

17481
2cjqymwy normal

Perfect, congrats from Brazil. muito obrigado!

over 1 year ago ·
18082
None

thanks a lot! that worked....

over 1 year ago ·
18083
10309058 10152457564452360 4465802230248535815 n

welcome :)

over 1 year ago ·