Search code examples
wordpressduplicatescustomizationadmin

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:

http://leojarina.info/stock-data/images/screenshot.jpg

How can I fix this? Please help!


Solution

  • @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 ;)