Are you looking for a way to remove the screen options tab? These snippets can be useful in the case you made modifications to the admin and want to hide the screen options.
Instructions:
Add one of the following snippets to your theme’s functions.php file or in a site-specific plugin.
- This snippet will remove the screen options tab completely.
function remove_screen_options(){ return false; } add_filter('screen_options_show_screen', 'remove_screen_options');
manage_options
capability.
function remove_screen_options(){ return current_user_can( 'manage_options' ); } add_filter('screen_options_show_screen', 'remove_screen_options');
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: How to Create a Custom User Registration Form in WordPress and 43 simple WordPress themes to easily start a website.
Worked like a charm, thanks a lot.
How to only show some widget in dashboard?
for example, in woocommerce
I want to show woocommerce status widget for role shop manager
I am 100% confident that this will not remove anything checked inside the screen options. Some themes can come up with their own screen options which is usually checked by default. This code will not remove them. So it is useless.
We have tested it and at the moment it is working. Screen options are not directly part of the theme, though theme code could influence them.
The api call
add_filter(‘screen_options_show_screen’, ‘remove_screen_options’);
does not work on version wordpress 5.2.4 please update the article.
Be sure to add the whole snippet. Adding
add_filter(‘screen_options_show_screen’, ‘remove_screen_options’);
by itself will not work. From testing it, the snippet works on WordPress 5.3.