Using WordPress ‘contextual_help_list’ PHP filter

The contextual_help_list WordPress PHP filter allows you to modify the legacy contextual help list.

Usage

add_filter('contextual_help_list', 'your_custom_function', 10, 2);

function your_custom_function($old_compat_help, $screen) {
  // Your custom code here
  return $old_compat_help;
}

Parameters

  • $old_compat_help (array) – Old contextual help.
  • $screen (WP_Screen) – Current WP_Screen instance.

More information

See WordPress Developer Resources: contextual_help_list

Examples

Modify contextual help for a specific screen

Update the contextual help content for the “edit” screen.

add_filter('contextual_help_list', 'modify_contextual_help', 10, 2);

function modify_contextual_help($old_compat_help, $screen) {
  if ('edit' === $screen->id) {
    $old_compat_help = 'New contextual help content for the edit screen.';
  }
  return $old_compat_help;
}

Add contextual help to custom post type

Add contextual help content to a custom post type screen.

add_filter('contextual_help_list', 'custom_post_type_help', 10, 2);

function custom_post_type_help($old_compat_help, $screen) {
  if ('edit-your_custom_post_type' === $screen->id) {
    $old_compat_help = 'Custom help content for your custom post type.';
  }
  return $old_compat_help;
}

Remove contextual help from all screens

Remove contextual help from all screens in the WordPress admin area.

add_filter('contextual_help_list', 'remove_all_contextual_help', 10, 2);

function remove_all_contextual_help($old_compat_help, $screen) {
  return '';
}

Add contextual help to a custom plugin page

Add contextual help content to a custom plugin page.

add_filter('contextual_help_list', 'custom_plugin_page_help', 10, 2);

function custom_plugin_page_help($old_compat_help, $screen) {
  if ('your-plugin_page_your-custom-page' === $screen->id) {
    $old_compat_help = 'Help content for your custom plugin page.';
  }
  return $old_compat_help;
}

Change contextual help based on user role

Modify contextual help content depending on the user role.

add_filter('contextual_help_list', 'user_role_based_help', 10, 2);

function user_role_based_help($old_compat_help, $screen) {
  $user = wp_get_current_user();

  if (in_array('administrator', $user->roles)) {
    $old_compat_help = 'Administrator specific help content.';
  } elseif (in_array('editor', $user->roles)) {
    $old_compat_help = 'Editor specific help content.';
  }

  return $old_compat_help;
}