2

I'm creating a plugin which generates a handfull or custom post types (CPT). I've create a top level menu in the admin left sidebar using add_menu_page(). I then added all CPTs to this menu using register_post_type()'s show_in_menu option. I also created a plugin settings page using add_submenu_page(), which I also added to the top menu.

My problem is that I can't get the settings page to appear above the CPT pages in the submenu. I make the register_post_type() call in an "init" action, and I make the add_submenu_page() call in a "admin_menu" action (which happens after "init"). So, it makes sense that the CPT pages come first. I can't move the register_post_type() calls to later in the process (it's too late to register a CPT, and I can't move the add_submenu_page() earlier (it's not defined earlier).

Do I just have to live with it?

1 Answer 1

3

you can use the menu_order filter hook to change the order

function custom_menu_order($menu_ord) {
       if (!$menu_ord) return true;
       return array('settings_page.php', 'edit.php?post_type=CTP1','edit.php?post_type=CTP2','edit.php?post_type=CTP3');
}

add_filter('custom_menu_order', 'custom_menu_order');
add_filter('menu_order', 'custom_menu_order');
1
  • Unfortunately, I'm trying to reorder submenu items. This would only reorder top menu items.
    – Matt
    Aug 8, 2011 at 23:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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