Support » Plugins » Hacks » menu_order not working with slugs that start with admin.php

  • I am filtering the menu_order hook (codex link) to change the order of my links in the admin menu. Currently the ordering will not work on slugs that begin with admin.php, so a settings page with the slug “admin.php?page=custom_settings_page” will just go to the bottom of the list. Anyone know of a workaround for this?

    //change admin menu order
    add_filter('custom_menu_order', 'my_custom_menu_order'); // Activate custom_menu_order
    add_filter('menu_order', 'my_custom_menu_order');
    
    function my_custom_menu_order($menu_ord){
    
    if(!$menu_ord) return true;
    return array(
        'index.php', //dashboard
        'separator1', //first separator
        'edit.php', //posts
        'edit.php?post_type=custom_post_type1', //custom post type 1
        'edit.php?post_type=custom_post_type2', //custom post type 2
        'edit.php?post_type=custom_post_type3', //custom post type 3
        'upload.php', //media
        'separator2', //second separator
        'admin.php?page=gf_edit_forms', //THIS GOES TO THE BOTTOM
        'edit.php?post_type=page', //pages
        'edit-comments.php', //comments
        'separator-last', //last separator
        'themes.php', //appearance
        'admin.php?page=custom_settings_page', //THIS GOES TO THE BOTTOM
        'plugins.php', //plugins
        'users.php', //users
        'tools.php', //tools
        'options-general.php' //WordPress options
    );
    
    }
  • The topic ‘menu_order not working with slugs that start with admin.php’ is closed to new replies.