I am developing a plugin and I want to add a menu under the woo-commerce marketing menu like the coupons and overview submenus. How am able to archieve that?
I did this but it didn't work.
add_submenu_page(
'admin.php?page=wc-admin&path=/marketing',
__( 'Sub Menu' ),
'manage_woocommerce',
'sub-menu-slug',
'sub_menu_page_callback'
);
I am developing a plugin and I want to add a menu under the woo-commerce marketing menu like the coupons and overview submenus. How am able to archieve that?
I did this but it didn't work.
add_submenu_page(
'admin.php?page=wc-admin&path=/marketing',
__( 'Sub Menu' ),
'manage_woocommerce',
'sub-menu-slug',
'sub_menu_page_callback'
);
Share
Improve this question
asked Mar 11, 2022 at 8:41
Isakiye AfashaIsakiye Afasha
1371 silver badge8 bronze badges
1 Answer
Reset to default 3If available the $GLOBALS[ 'menu' ]
array holds data for each top level menu item in the dashboard, and in the sub array for the Woocommerce "Marketing" menu item, key 2 has the value you're looking for: "woocommerce-marketing"
.
So with that your add_submenu_page
should look like the below to make your sub menu item show up under the Woocommerce Marketing menu item:
add_submenu_page(
'woocommerce-marketing',
__( 'Sub Menu' ),
'manage_woocommerce',
'sub-menu-slug',
'sub_menu_page_callback'
);