Duplicated Label in add_menu_page

I have created a function for a theme customization.

function create_theme_option() {

        add_menu_page(  'Manage Options', //Page Title 

                        'Theme Option', //WP Administrator Menu Title

                        'manage_options', //

                        'theme-options', //Link to a page to your Administration Area

                        'deploy_theme_options', //Function Name

                        get_template_directory_uri() . '/Plugins/Background Changer/images/icons/icon.png',//Menu Icon 

                        99);

        add_submenu_page("theme-options", "Theme Settings", "Theme Settings", 1, "theme-settings", "theme_settings");

        add_submenu_page("theme-options", "Manage Header", "Manage Header", 1, "manage-header", "manage_header");

        add_submenu_page("theme-options", "Social Media", "Social Media Links", 1, "social-media", "social_media");

        add_submenu_page("theme-options", "Catalog Manager", "Catalog Manager", 1, "catalog-manager", "catalog_manager");

    }

but I noticed that after the label "Theme Option" there is another text appear next to it as "Theme Option". Check the Image below:

How can I fix this? Please help!

Answers


@Basharat was pretty close. Here is a cleaner way I use in my plugins:

add_menu_page(
    '',                     // No need to have this
    'My Plugin',            // Menu Label
    'manage_options',
    'my_plugin_settings',   // (*) Shared slug
    'your_function',
    plugins_url('myplugin/images/icon.png'),
    81
);

add_submenu_page(
    'my_plugin_settings',   // (*) Shared slug
    'My Plugin Settings',   // Subpage Title
    'Settings',             // Submenu Label
    'manage_options',
    'my_plugin_settings',   // (*) Shared slug
    'your_function'
);

Source: Coffee, trial and error ;)


For fix this issue you can use the remove_submenu_page, http://codex.wordpress.org/Function_Reference/remove_submenu_page.

example:

remove_submenu_page ('my-menu-slug','my-menu-slug')


I think you should check the capability parameter which should not be 99

http://codex.wordpress.org/Function_Reference/add_menu_page


Please use below to remove the duplicate entry of Menu in Sub-Menu.

<?php 
/* Add top level menu */
add_menu_page(
    'MyTheme', 
    'MyTheme Menu Label',
    'edit_themes', 
    'theme_admin',        // menu slug
    'functions.php',        // function
    get_bloginfo('template_directory') .'/img/favicon.png',
    31
);

/* remove duplicate menu hack */
add_submenu_page(
    'theme_admin',        // parent slug, same as above menu slug
    '',        // empty page title
    '',        // empty menu title
    'edit_themes',        // same capability as above
    'theme_admin',        // same menu slug as parent slug
    'functions.php',        // same function as above
}
?>

This isn't too clean, but afaik the only way to hide the duplicate submenu.

Reference: https://wordpress.stackexchange.com/questions/52675/how-to-remove-duplicate-link-from-add-menu-page


The only working way i found is to set the add_menu_page $capabilties to unknown, so something like 'unknown', this will hide the page or the submenu, but the menus will still be shown on the left side.


Need Your Help

reconfiguring NLog programmatically

.net logging nlog

This is my first time using the NLog package for logging but so far its been great to work with.

'SImple' 2 class Java calculator doesn't accept inputs or do calculations

java swing

I'm trying to get a two class java calculator working (new to java) but so far i'm having no success. the two classes are outlined below, calcFrame is for the interface and calEngine should do the