0

I have couple of main admin menus and sub-menuse underneath them.

Main menu1
      Sub menu 1
      sub menu 2
      sub menu 3
Main menu2
      Sub menu 1
      sub menu 2
      sub menu 3

Like above.

I use following code block to create the main menu1

function register_myplugin_admin() {
    add_menu_page(
        __( 'Main menu1', 'textdomain' ),
        'Main menu1 ',
        'manage_options',
        '/myplugin/includes/admin-menu.php',
        '',
        plugins_url( 'myplugin/images/icon.png' ),
        6
    );
}

add_action( 'admin_menu', 'register_myplugin_admin' );

Since all these are menu appear as open, i am thinking of the possibility of collapsing these menus to the parent level

i.e Main Menu1 & Main Menu 2 are displayed, and upon user click of main menu 1 or main menu 2, the relevant section gets expanded / visible to the user.

is there any way to achieve this through WordPress actions / hooks or filters?

  • edit your question to show the code which defined a main menu. – mmm Apr 21 '18 at 18:29
  • edited the question to show the code. – Shirantha Apr 21 '18 at 18:40
0

I use plugin called ubermenu and have paid for the deluxe version of it. You can customize all types of things within a menu that's much more extensive than built-in functionality. I think the cost of ten bucks or so is well worth it. Add plugin----> Ubermenu in search field then install and activate. Then customize to your heart's content.

  • No, I want to do this without using an external plugin as a dependency. – Shirantha Apr 22 '18 at 3:39
  • I guess. I don’t know if you can – Webmaster TheCMG Apr 22 '18 at 4:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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