Alter the contextual help in WordPress

Here’s a quick example of how to alter the contextual help menu in WordPress. It’s up there on the top right when you are in the admin view. Shannon asked a question about it in the Reclaim Discord server and I figured I’d start off my morning with a tiny programming exploration.

There a few things you might want to do to the contextual help menu. You might want to remove all the stuff and just put in your own help stuff1, or maybe you want to remove one element of the help menu, or you want to add a custom help option.

Thankfully, there was a StackOverflow post that hit some of these options. I modified it a bit to expand on some additional choices.

You can see it below with at attempt at explaining things in the comments. You can run this in a multisite as part of your handy network activated functions or add it as part of a theme or plugin to run on individual sites. That’d be helpful if you built a custom theme for a program to use in portfolios and wanted to provide specific guidance for those users. Definitely some neat options if you can take the overhead of meeting that kind of personalized expectation.

function wpse50787_remove_contextual_help() {
    $screen = get_current_screen(); //could use an if statement to only do this on certain pages based on what's returned here
    //$screen->remove_help_tabs(); // uncomment this to remove all the existing help content
    //$screen->remove_help_tab('overview'); // uncomment this and change the ID argument to remove specific help menu items, to get ids var_dump $screen and look at the _help_tabs array
    //this portion adds an item to the contextual help menu
      $screen->add_help_tab( array(
          'id'      => 'umw-help',
          'title'   => __('?? Get Midd Help', 'sfc'),//title in the menu
          'content' => "<h2>Foo Bar Buzz</h2><p><a href=''>Midd WP help</a></p>",//body HTML
          'priority' => 1,//make it the first item with a 1 priority or erase to have at the end
      ) );
add_action( 'admin_head', 'wpse50787_remove_contextual_help' );

1 A bit crazy to me, but who am I to judge?

Leave a Reply