WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just want to make/add a Menu (Ads) that contains two submenus (View, Manage). My code is written below. The problem is that I don't know why it's popping another submenu in the main menu.

function Ad_menu() {
    // Main menu
    add_menu_page( 'Ads', 'Ads', 'manage_options', 'ad_menu', 'Main_Menu');

    // Submenus
    add_submenu_page( 'ad_menu', 'View', 'View', 'manage_options', 'View', 'View');
    add_submenu_page( 'ad_menu', 'Manage', 'Manage', 'manage_options', 'Manage', 'Manage');
add_action('admin_menu', 'Ad_menu');
share|improve this question
Please use proper English, punctuation, readable code formatting etc. Questions are references to other users and people take their time to help you for free, so take the time to format your question as good as possible. – kaiser Oct 18 '13 at 6:49
Try to give meaningful/unique names to each the slug and the callback: Function_Reference/add_submenu_page As you're using, it will only lead to confusion. – brasofilo Oct 18 '13 at 8:15

The third menu item that appears (in fact, the first) is the main menu:

enter image description here

add_action('admin_menu', 'Ad_menu');

function Ad_menu()
    //Main menu
        'Ads page title', 
        'Ads menu title', 
        function(){ echo '<h1>Main menu</h1>'; }
        'View page title', 
        'View menu title', 
        'ad_view_slug', // <-- Put main menu slug here
        function(){ echo '<h2>Views submenu</h2>'; }
        'Manage page title', 
        'Manage menu title', 
        function(){ echo '<h2>Manage submenu</h2>'; }

If you change the first submenu slug to ad_menu_slug (the main menu slug), the result will be this:

enter image description here

share|improve this answer
I have included my view and manage submenu pages on this menu page(Ads) through view and manage functions, but now they are showing up in the ads menu page. – pd4627 Oct 18 '13 at 8:01
As I understand it, you don't want to join the 3 menus in 1, is it? So, why adding "manage" to the main menu? – brasofilo Oct 18 '13 at 8:04
I want a main menu(ads) having 2 submenus(view & manage). Now i want to show my view & manage codes in different pages not in the main menu page. – pd4627 Oct 18 '13 at 8:07
So what's the problem? You only have to change the Views submenu slug, as shown in the Answer. Leave "Manage" as it is. – brasofilo Oct 18 '13 at 8:09
Ya that worked fine for me,thanks for that. But now my view and manage pages are shown on the same main menu page. – pd4627 Oct 18 '13 at 8:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.