The order of the menu items can be changed using the filter menu_order
add_filter( 'menu_order', 'se354759_menu_order' );
add_filter( 'custom_menu_order', '__return_true' );
function se354759_menu_order ($menu_order)
{
$cpts = [
'edit.php?post_type=" . "custom-post-type',
'edit.php?post_type=" . "another-cpt'
];
//
// remove and save first item ("dashboard") in variable
$first_item = array_shift( $menu_order );
foreach( $cpts as $ctp )
{
$idx = array_search( $ctp, $menu_order );
if ( $idx === false )
continue;
//
// remove CPT menu item from array
unset( $menu_order[$idx] );
//
// add CPT item to the beginning of the array
array_unshift( $menu_order, $ctp );
}
//
// re-add "dashboard" item
array_unshift( $menu_order, $first_item );
return $menu_order;
}
Related Posts:
- Menu position (admin menu) of pages
- Is It Possible To Add Custom Post Type Menu As Another Custom Post Type Sub Menu
- Placing a Custom Post Type Menu Above the Posts Menu Using menu_position?
- Custom Post Type Settings page, choose page to display archive
- Put update-like notification bubble on multiple CPTs menus for pending items
- Meta Boxes: ‘admin_init’ or ‘add_meta_boxes’ hook?
- Show Custom Taxonomy Inside Custom Menu
- Remove “posts” from admin but show a custom post
- Can I have Post Types under other Post Types in Admin menu?
- Is it OK to move admin menu items?
- How Do I Programmatically Better Organize Custom Post Type Menus?
- Add Post type menu to another menu
- How do I create multiple post types in same menu section in WP-admin?
- Is there a way to keep a custom menu expanded when editing a custom post type?
- How to remove/hide elements from the admin menu?
- Remove Custom Post Type menu for non-administrator users.
- How do I code access to the built-in UI of a CPT when it’s placed as submenu of another CPT that is protected by role?
- Custom Post Type and taxonomies’s labels localization not working
- how to only have one custom post type post?
- How can I use a different default admin menu icon for custom post type?
- How to allow “Add New” capability of CPT when links to its UI are placed as a submenu?
- How to add new tab to admin list of posts and handle result list
- Displaying different custom post types under one admin menu
- Add management screens to post type
- How do I alter the position of a Custom Post Type menu item within my plugin admin menu?
- How to add custom post type under option page
- How to remove default tag and category options form a custom post type admin menu
- Prevent custom taxonomy from being added to admin menu?
- Trying to add script to specific admin page is not working
- Custom Post Type / Tab Limit
- rewrite custom post type slug in wp admin
- How do increase the amount of links shown down the left in the admin menu?
- Move custom post menu to under plugin admin menu
- Insert & order custom post types in/as submenu
- With two custom post types, how to make one a child of the other in the admin menu?
- Custom post types as sub menu pages and role capabilities issue
- Sort CPT archive by order prevents sorting in admin
- How to display Custom Taxonomy under Custom Admin Menu?
- How to order WP_Query by parent for hierarchical Custom Post Type?
- Able to edit custom post, but unable to create new custom post when within submenu. What capability is missing?
- Add Custom Post Type as top level menu item for a custom page
- Possibilities for the edit.php admin panel? [closed]
- Add Custom Post type menu to another menu in specific location
- How to remove post listing page for a custom post type
- 2 Different Custom Post Types in Submenu
- Ordering Submenu Pages in WP 3.1
- How to group navigation items in the admin panel
- Conflict between Capabilities and Menu Visibility with Custom Post Types
- Getting post attchment URL to populate a CPT Admin Page Column
- How to add query args to links to CPT admin submenu
- Reusable metabox backend and frontend
- Multiple custom post types showing up in edit.php
- Top level menu position overwrites another entry
- admin_head-post.php only works after publish / update
- adding page types in menu
- “Menu order” being ignored when querying posts from a parent taxonomy with “include_children” set to true
- Metaboxes inside Tab
- Restrict admin pages for specific user role
- Cannot include custom post item within a menu
- How can i redirect click to new admin page not to edit screen in post table
- Is there a way to display a custom post type menu item as “users” submenu?
- remove duplicate name submenu link from the custom post type
- Subset of Custom Post Type From Admin Menu Based on Meta Data
- How to override post-new.php with custom template
- Setting up a page to house certain types of posts
- Changing menu label to post name for custom post type
- Show custom taxonomy not in submenu
- Duplicate “Pages” Item in Admin Menu
- Query posts from multiple post types sorted by overarching menu order
- How to add elements to WordPress appearance->menu admin?
- How to avoid hardcoded text in a custom page template?
- Limit number of posts under a post type?
- Custom Post Type Causing Admin Sidebar UI Issue
- Issue on CPT Custom Menu Position in WP
- Custom Taxonomy Showing in WP Menu
- Show custom taxonomies in admin panel under custom post type
- Add top-level menu pointing to a different custom post type?
- Separating a custom taxonomy from blog post-type
- wordpress custom post type shows other cpt posts in admin menu
- Custom post types not showing in the admin menu on production, but shows locally
- Admin menu link with variable
- Can’t add custom post type archive page to menu
- Unable to get wp_redirect() working after adding a CPT via the front end
- Post Link Filter Help [closed]
- Custom Post Type “Event” with custom permalink structure
- How to associate two different post types (think Book and Chapter)
- Different Archive and Single Permalink URL
- Undefined Variable – Custom Post Type Meta
- filter custom post type by meta key in dashboard
- Use a hierarchical custom post type for a main blog and subblogs?
- Add additional field to custom post_type
- Is it possible to filter the display name for post formats for display in the Formats meta box?
- Sort a custom post with ACF: Date Picker & Display Featured!
- Adding custom post formatting options in custom post types
- Better in the long run to use post date or custom taxonomy to sort/separate posts by year?
- Template hierarchy changes when custom post-type permalink leverages custom taxonomy
- How to use costum database table for custom post type
- Custom Post Type Pagination Not Working or Single Posts Displaying?
- Custom metabox value not saving
- WordPress custom field sorting, weird behavior: the latest post is at the end