Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to remove menu items from the backend but for some reason I can't remove specific menu items added by plugins. For example, I can use this line to remove the plugins page and it works just fine:

remove_menu_page('plugins.php');

I have a plugin, CW Image Optimizer, that adds a sub menu under the Settings menu. The php file the plugin uses is named cw-image-optimizer.php. If I use the following line to remove the sub menu it doesn't work:

remove_submenu_page('options-general.php', 'cw-image-optimizer.php');

Is there something specific I need to do to remove menu and sub menu items added by plugins?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I'll assume you're calling it in your functions.php file?

If that's the case, likely the plugin is adding the menu item after you're call is being called. Try placing it in the admin_init() hook, at the very end.

if ( ! function_exists( 'remove_wp_menu_items' ) ) {
function remove_wp_menu_items() {
    remove_submenu_page( 'themes.php', 'theme-editor.php' );
}
}
add_action( 'admin_init', 'remove_wp_menu_items', 999 );

http://codex.wordpress.org/Function_Reference/remove_submenu_page http://codex.wordpress.org/Function_Reference/add_action

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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