Reputation: 1685
I have created an admin menu in wordpress with these functions:
function list_menu(){
add_menu_page( 'My Plugin', 'My Plugin', 'administrator', 'mylist', 'list_page', plugins_url('favicon.png'), 24);
}
add_action('admin_menu', 'list_menu');
function add_menu(){
add_submenu_page( 'mylist', 'Add New', 'Add New', 'administrator', 'add_new_page', 'add_page');
}
add_action('admin_menu', 'add_menu');
But it create a menu with duplicate value in the menu like this:
Is there a way to let the menu like this:
=> My Plugin
===> All Posts
===> Add New
Upvotes: 0
Views: 83
Reputation: 1966
can you plz try this code.
<?php
function edit_admin_menus() {
global $menu, $submenu;
$menu[24][0] = 'My Plugin'; // TO change admin parent menu
$submenu['mylist'][0][0] = 'All Posts'; // To change child menu of "My Plugin" parent
}
add_action( 'admin_menu', 'edit_admin_menus' );
?>
Thanks.
Upvotes: 1