WordPress.org

Ready to get started?Download WordPress

Forums

Double top-level and sub-level menu item (3 posts)

  1. Libor Jelinek
    Member
    Posted 6 years ago #

    Hi all!
    Adding top-level menu page item (next to Publish, Manage, Look&Feel, Comments) also adds subpage with the same name. But I don't want it!

    add_menu_page('MyMenu', 'MyMenu', 7, __FILE__);
    add_submenu_page(__FILE__, 'Submenu 1', 'Submenu 1', 7, 'submenu1', 'print_submenu_1');
    add_submenu_page(__FILE__, 'Submenu 2', 'Submenu 2', 7, 'submenu2', 'print_submenu_2');

    Creates:

    Publish | Manage | Look&Feel | MyMenu |
    +----------------------------|        |---------------+
    | MyMenu | Submenu 1 | Submenu 2                      |
    |                                                     |
    |                                                     |
    |                                                     |
    +-----------------------------------------------------+

    But I don't want to have "MyMenu" again on submenu level... It doesn't have any sence for me. When I click to "MyMenu" top-level I want to see "Submenu 1".

    How to get rid of double "MyMenu" top-level and sub-level items?

    Thanks
    Libor

  2. Dazzer
    Member
    Posted 6 years ago #

    add_menu_page('MyMenu', 'MyMenu', 7, __FILE__);
    add_submenu_page(__FILE__, 'Submenu 1', 'Submenu 1', 7, 'submenu1', 'print_submenu_1');
    add_submenu_page(__FILE__, 'Submenu 2', 'Submenu 2', 7, 'submenu2', 'print_submenu_2');

    Change to

    add_menu_page('MyMenu', 'MyMenu', 7, __FILE__);
    add_submenu_page(__FILE__, 'Submenu 1', 'Submenu 1', 7, __FILE__, 'print_submenu_1');
    add_submenu_page(__FILE__, 'Submenu 2', 'Submenu 2', 7, 'submenu2', 'print_submenu_2');

    Should work

  3. Akashic
    Member
    Posted 6 years ago #

    The 'duplicate' submenu vanishes, but (at least in my case) after selecting MyMenu, there was no page contents.

    So as to display sth, I've used this:

    add_menu_page('MyMenu', 'MyMenu', 7, __FILE__, 'print_submenu_1');
    add_submenu_page(__FILE__, 'Submenu 1', 'Submenu 1', 7, __FILE__, 'print_submenu_1');
    add_submenu_page(__FILE__, 'Submenu 2', 'Submenu 2', 7, 'submenu2', 'print_submenu_2');

Topic Closed

This topic has been closed to new replies.

About this Topic