I'm using WordPress 4.9.1 and WooCommerce 3.2.6.
I have added a new Custom Post Type (Subscriptions) and inserted the menu item under the 'WooCommerce' menu in the admin panel using 'show_in_menu' => 'woocommerce'
, but I want to move my post type immediately under 'Orders'.
I have tried changing menu_position
but it doesn't have any effect.
register_post_type('subscription',
array(
'labels' => array(
'name' => __( 'Subscriptions' ),
'singular_name' => __( 'Subscription' ),
'add_new_item' => "Add New Subscription",
'edit_item' => "Edit Subscription",
),
'public' => true,
'has_archive' => false,
'publicly_queryable' => false,
'show_in_rest' => false,
'show_in_menu' => 'woocommerce',
'menu_position' => 9999,
'supports' => array(
'title',
'revisions'
)
)
);
SOLUTION:
I changed show_in_menu
to false
when registering my post type, and added the following code:
function add_subscriptions_menu() {
add_submenu_page('woocommerce','Subscriptions','Subscriptions', 'manage_options', 'edit.php?post_type=subscription');
}
// Change the 30 to customise item's order within WooCommerce submenu.
add_action( 'admin_menu', 'add_subscriptions_menu', 30 );