Forums

Moving custom Admin menu item up the list (7 posts)

  1. semus
    Member
    Posted 2 years ago #

    Hi,

    I have created a new menu for my plugin and it works fine, however I would like to move the position of the menu link on the admin page higher up in the list. It is currently right at the bottom below Settings and I would ideally like to have it below Posts.

    Note: I don't want it as a submenu under posts, I know how to do that already!

    Thanks in advance for your help!

    :)

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    Not really up on this, but, using the example at http://codex.wordpress.org/Adding_Administration_Menus#Inserting_the_Pages

    and changing

    // Add a new top-level menu (ill-advised):
        add_menu_page('Test Toplevel', 'Test Toplevel', 'administrator', 'mt-top-level-handle', 'mt_toplevel_page');

    to this will cause Test Toplevel to be displayed after the Posts menu items. It's that 10 which is the 'position' value.

    // Add a new top-level menu (ill-advised):
        add_menu_page('Test Toplevel', 'Test Toplevel', 'administrator', 'mt-top-level-handle', 'mt_toplevel_page','',10);
  3. semus
    Member
    Posted 2 years ago #

    Hi MichaelH,

    That doesn't work :(

    Where did you read that adding those extra values would change the position?

    Any other ideas?

  4. MichaelH
    Volunteer
    Posted 2 years ago #

    Worked okay for me when I put it in the form of a plugin.

    Also found out about the 'postition' argument here--you have to look at the add_menu_page function down that page:
    http://phpxref.ftwr.co.uk/wordpress/nav.html?_functions/index.html

  5. ethicus
    Member
    Posted 2 years ago #

    Hi MichealH,

    I was looking in the codex and couldn't find the extra argument you put in the add_menu_page. What does it do exactly?

    btw it does work but I was just wondering why??

  6. MichaelH
    Volunteer
    Posted 2 years ago #

    It's the position thing, but I can't 'really explain it' except to suggest looking at that link I provided. Not much help...sorry.

  7. paulpicauly
    Member
    Posted 2 years ago #

    It's a little bit trial and error. Be careful though: if you use the wrong value it causes other menu-items to disappear. Using '20' caused my plugin to replace the 'Pages' menu item.

Topic Closed

This topic has been closed to new replies.

About this Topic