I just figured out the menu_position parameter it seems like you can place the menu of your custom post type almost everywhere. Except above the Posts menu!
How can I accomplish that?
I just figured out the menu_position parameter it seems like you can place the menu of your custom post type almost everywhere. Except above the Posts menu!
How can I accomplish that?
You must be logged in to post a comment.
Positions for Core Menu Items
Parameter description for “menu position”
The new JetPack Plugin places its menu link immediately below the Dashboard link. It does so by setting its menu order to 0, by filtering the $menu_order array:
Out of curiosity, what would happen if you tried 0 as menu_position?
Looking for a solution on the web but didn’t found. Simply does this trick (for example). Here you have the native list of positions:
If you have more items, you can read the current position for each items by printing the global $menu :
So if I well understand, nothing can prevent us too re-order the menu like we want :
It works fine for me so, I think this is legit, I’m wrong ?
I’ve used ‘menu_postion’ => 0, 1,2,3,4.
Doesn’t matter really. If you play around with it you can easily figure it out.
Using ‘menu_position’ => 1 should place it below the Dashboard menu item above the separator thing. 0 Should place it above the Dashboard
This is a bug in WordPress. Please see this thread in Trac: http://core.trac.wordpress.org/ticket/14755
Fixed in 4.4…
https://developer.wordpress.org/reference/functions/add_menu_page/#notes
You can use this:
Now you can use position 5 to add you menu above Post menu.
here is the caveat to the whole issue…
WordPress 4.9.2
wp-admin/menu.php:
NOTICE: must be an integer and NOT set already, otherwise it goes to the bottom of the list.
For a working solution in WordPress 5 and below, reposition it with the following code:
This assumes you don’t have more than one menu item vying for pole position.
On the same link you linked, it reads:
So, if you set
menu_position
to something like4
, then it should put it above posts.A position of
-1
puts it above theDashboard
link.You can use decimal values (as strings). For example, I have some custom post types that I placed at the last position in menu (100001, 100002, 100003).
Then, just put this code to move them above Posts and below Dashboard menu items.