Using WordPress ‘contextual_help’ PHP filter

The contextual_help WordPress PHP filter allows you to modify the legacy contextual help text displayed on the admin screen.

Usage

add_filter('contextual_help', 'your_custom_function', 10, 3);

function your_custom_function($old_help, $screen_id, $screen) {
  // your custom code here
  return $old_help;
}

Parameters

  • $old_help (string) – The original help text that appears on the screen.
  • $screen_id (string) – The unique identifier for the current admin screen.
  • $screen (WP_Screen) – The current WP_Screen instance.

More information

See WordPress Developer Resources: contextual_help

Examples

Change help text for the post editing screen

Modify the help text on the post editing screen.

add_filter('contextual_help', 'change_post_edit_help', 10, 3);

function change_post_edit_help($old_help, $screen_id, $screen) {
  if ('post' == $screen_id) {
    $old_help = 'Custom help text for the post editing screen.';
  }
  return $old_help;
}

Change help text for a custom post type

Modify the help text for a custom post type called ‘product’.

add_filter('contextual_help', 'change_product_help', 10, 3);

function change_product_help($old_help, $screen_id, $screen) {
  if ('edit-product' == $screen_id) {
    $old_help = 'Custom help text for the product editing screen.';
  }
  return $old_help;
}

Add help text to a custom admin page

Add help text to a custom admin page with the screen ID ‘custom_page’.

add_filter('contextual_help', 'add_custom_page_help', 10, 3);

function add_custom_page_help($old_help, $screen_id, $screen) {
  if ('custom_page' == $screen_id) {
    $old_help = 'Help text for the custom admin page.';
  }
  return $old_help;
}

Remove help text from a specific screen

Remove help text from the ‘Appearance’ > ‘Menus’ screen.

add_filter('contextual_help', 'remove_menus_help', 10, 3);

function remove_menus_help($old_help, $screen_id, $screen) {
  if ('nav-menus' == $screen_id) {
    $old_help = '';
  }
  return $old_help;
}

Change help text based on user role

Modify the help text based on the current user’s role.

add_filter('contextual_help', 'change_help_based_on_role', 10, 3);

function change_help_based_on_role($old_help, $screen_id, $screen) {
  if (current_user_can('manage_options')) {
    $old_help = 'Help text for administrators.';
  } else {
    $old_help = 'Help text for non-administrators.';
  }
  return $old_help;
}