1

I have a simple solution in my functions.php for reordering the admin menu. Here it is:

// Admin menu - reorder
function custom_menu_order($menu_ord){
  if (!$menu_ord) return true;
  return array(
    'index.php', // Dashboard
    'edit.php?post_type=page', // Pages
    'edit.php?post_type=shop_order', // WooCommerce
    'edit.php?post_type=product', // Products
    'gf_edit_forms', // Forms
    'upload.php', // Media
    'separator1', // First separator
    'separator2', // Second separator
    'separator-last', // Last separator
    'users.php', // Users
    'themes.php', // Appearance
    'options-general.php', // Settings
    'plugins.php', // Plugins
    'tools.php', // Tools
    'itsec', // Security
    'edit.php?post_type=acf-field-group', // Custom Fields
    'edit.php?post_type=cptm' // Post types
  );
}
add_filter('custom_menu_order', 'custom_menu_order');
add_filter('menu_order', 'custom_menu_order');

This works just fine, except this one item does not work:

'edit.php?post_type=shop_order', // WooCommerce

It just shows up at the bottom of the menu, everything I try to do to make it show up in the proper order fails. I believe the issue is the post_type name shop_order. It's the underscore that I think is making it fail.

Any thoughts on why that might be? Please don't say to use a plugin as the goal of this is to avoid using additional plugins. Thank you!

4

The actual slug for the WooCommerce menu item is 'woocommerce'.

So if you replace:

'edit.php?post_type=shop_order', // WooCommerce 

with:

'woocommerce', // WooCommerce 

the above code will work.

I found a handy function that will display all the items in the menu array at How to remove admin menu pages inserted by plugins?.

Here is the function (from the above link) that I use when reordering menu items:

function my_debug_admin_menu() {
    echo '<pre style="margin-left:200px;">' . print_r( $GLOBALS[ 'menu' ], TRUE) . '</pre>';
}
add_action( 'admin_init', 'my_debug_admin_menu' );
| improve this answer | |
  • Thank you! It worked, and thank you for the other info as well. I'm sure I'll use that in the future. – bcoyour Oct 9 '15 at 14:39

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.