How to Change WP Default Sub Menu Class

WordPress sub menu has always a default class. Default class name is “sub-menu”.

In this tutorial, we are going to see how to Change default sub menu class in WordPress.

To change it to custom class add given below code to functions.php

add it to functions.php

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

Hope you have got how to change class in sub-menu (WordPress). If you have any query regarding this article,feel free to comment.

Leave a Comment