Additional menu item popping in submenus

The third menu item that appears (in fact, the first) is the main menu: add_action(‘admin_menu’, ‘Ad_menu’); function Ad_menu() { //Main menu add_menu_page( ‘Ads page title’, ‘Ads menu title’, ‘manage_options’, ‘ad_menu_slug’, function(){ echo ‘<h1>Main menu</h1>’; } ); //Submenus add_submenu_page( ‘ad_menu_slug’, ‘View page title’, ‘View menu title’, ‘manage_options’, ‘ad_view_slug’, // <– Put main menu slug here function(){ … Read more

Add Labels to Admin Menu ( How To )

First of all, searching with wrong keyword won’t give you any right solution. It’s a hint that, you are dealing with Admin menu, and anything under a menu drop down is called a sub menu – so you should search with something like: How to add submenu to any admin menu item + WordPress?. 🙂 … Read more

Insert a div class inside wordpress menu

I think use Custom Walker. First register a custom navigation menu for this list in your theme’s functions.php class WP_Walker extends Walker_Nav_Menu { function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat(“\t”, $depth); $output .= “\n$indent<div id=’mega’><ul class=”sub-menu”>\n”; } function end_lvl( &$output, $depth = 0, $args = array() ) { … Read more

Print Dashboard submenu name and filename

If you want them in an unordered list: echo “<ul>\r\n”; foreach ( $submenu as $group => $item ) { foreach ( $submenu[$group] as $key => $value ) { echo “<li>” . $submenu[$group][$key][0] . ” > ” . $submenu[$group][$key][2] . “</li>\r\n”; } } echo “</ul>”; This results in: <ul> <li>Home > index.php</li> <li>Updates > update-core.php</li> <li>Library … Read more

Wrap list parent in div with wp_nav_menu menu

Since WordPress make use of Walkers you can extend the class Walker_Nav_Menu with your own and pass the instance of it to the function wp_nav_menu. So your call will be: <?php wp_nav_menu( array( ‘menu’ => ‘Main Menu’ ‘walker’ => new Custom_Nav_Walker() ) ); ?> Then in a separated file create the class Custom_Nav_Walker that will be … Read more