Add submenu class

How to add submenu class for making dynamic of static menu while doing html to wordpress, we can add submenu dropdown class on wp generated submenu list

< ?php
/**
 * Add submenu class
 */
function change_submenu_class($menu) {  
  $menu = preg_replace('/ class="sub-menu"/','/ class="dropdown-menu" /',$menu);  
  return $menu;  
}  
add_filter('wp_nav_menu','change_submenu_class');
?>

Menu and Sub menu Pages in Admin Panel

How to add menu and submenu in admin menus under admin dashboard

Given code to add menu and submenu in admin panel


Add menu page without creating any submenu or menu


Delete an Existing Sub-Menu

Finally, we may want to remove certain sub-menu elements. This may occur when we want to add a page but do not want it to be directly accessible from the main dashboard.
The function below allows us to remove a sub-menu based its unique menu-id and the unique submenu-id.

 $submenu_object) {
		if (in_array($submenu_name, $submenu_object)) {// remove menu object
			unset($submenu[$menu_name][$submenu_key]);
			return;
		}
	}           
}
// Add to end of admin_menu function        
remove_submenu('edit.php?post_type=theme', 'theme_options');
?>