I want to remove a few sub menu items from the admin menu in WordPress. I have found the following which can remove certain sub menu items...
add_action( 'admin_menu', 'adjust_the_wp_menu', 999 );
function adjust_the_wp_menu() {
$page = remove_submenu_page( 'themes.php', 'widgets.php' );
}
...but what if it is not a standard php such as "themes.php?page=custom-header" that I would like removed.
Add code in your function.php
Remove "themes.php?page=custom-header" option using this code.
function remove_twentyeleven_options() {
remove_custom_image_header();
}
add_action( 'after_setup_theme','remove_twentyeleven_options', 100 );
This worked for me. Thanks to Ravi for pointing me in the right direction.
add_action( 'init', 'remove_taxonomy_menu_pages', 999 );
function remove_taxonomy_menu_pages() {
// remove products->categories
register_taxonomy('product_cat',
'woocommerce_taxonomy_objects_product_cat', array('show_ui' => false)
);
// remove products->tags
register_taxonomy('product_tag',
'woocommerce_taxonomy_objects_product_tag', array('show_ui' => false)
);
// remove products->shipping classes
register_taxonomy('product_shipping_class',
'woocommerce_taxonomy_objects_product_shipping_class', array('show_ui' => false)
);
}
add_action( 'admin_menu', 'remove_submenu_pages', 999 );
function remove_submenu_pages() {
// remove products->attributes
remove_submenu_page( 'edit.php?post_type=product', 'woocommerce_attributes');
}
I would like to share, that's how you can remove woocommerce submenu's
- Product Attributes
- Product Shipping Class
--
add_action( 'admin_menu', 'remove_taxonomy_menu_pages', 999 );
function remove_taxonomy_menu_pages() {
remove_submenu_page( 'edit.php?post_type=product', 'product_attributes' );
remove_submenu_page( 'edit.php?post_type=product', 'edit-tags.php?taxonomy=product_shipping_class&post_type=product');
}