Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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');
share|improve this answer
    
Unfortunately, I'm trying to reorder submenu items. This would only reorder top menu items. –  Matt Aug 8 '11 at 23:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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