image description

How to Change WordPress Sub-Menu Class with Custom Class

we can use wordpress filter for change ‘sub-menu’ class. place below code in functions.php for replace ‘sub-menu’ class


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