How to target specific options pages in WordPress

I’m trying to remove screen options from a specific page and I’ve got something that removes screen options from all pages so I just need to check for “when page == {x}” How do I check what page I’m on in wordpress though?

function remove_screen_options(){
    return false;
}
add_filter('screen_options_show_screen', 'remove_screen_options');

Thought it would be as easy as:

Read More
    function remove_screen_options(){
  global $pagename;
  if( $pagename == "admin_faucet_settings") {
    return false;
  }
}
add_filter('screen_options_show_screen', 'remove_screen_options');

But that is not working – seems to fire all the time too which is strange and off…any ideas?

Related posts

Leave a Reply

1 comment

  1. So, if you need to target any particular page of wordpress admin area, such as plugin page then you can use admin enqueue script hook like this:

    function my_admin_enqueue($hook_suffix) {
        if($hook_suffix == 'faucet_admin_settings') {
          // your code that should be executed if we are on the right page.
        }
    }
    add_action('admin_enqueue_scripts', 'my_admin_enqueue');
    

    Reference: https://wordpress.stackexchange.com/questions/7278/how-can-you-check-if-you-are-in-a-particular-page-in-the-wp-admin-section-for-e