0

From looking at the codex and after using print_r($GLOBALS['menu']; to display the array list of menu items, I see my CPTs listed as

16,17,18,19 

in the returned array. 20 is the Pages menu item, and 15 as the Links menu item. I have a settings plugin which I wish to display with my Custom Posts. If I add

add_menu_page( 'Settings', 'Settings', 'manage_options', 'plugin_name', 'plugin_name_options_page', content_url( '/img/icon.png', __FILE__), 20 );

Then the Pages menu item is overwritten completely by my plugin entry, rather than being moved to 21 etc.

The array for the Posts section in the menu seems to end at 25, so I was thinking I have two options;

  1. Figure out how to insert my plugin into the menu array as 20 and move the other pages in the array further along by 1.
  2. Manually set the menu number for my plugin and my CPTs. I have the plugin menu code - how and where do I add similar functionality in my custom posts code?
1

Hmm, missed this codex page... To solve this the number should be passed as a decimal as a string rather than an int;

20 -> '19.1'

adjusted code;

add_menu_page( 'Settings', 'Settings', 'manage_options', 'plugin_name', 'plugin_name_options_page', content_url( '/img/icon.png', __FILE__), '19.1' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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