Using WordPress ‘dashboard_primary_title’ PHP filter

The dashboard_primary_title WordPress PHP filter allows you to modify the primary link title for the ‘WordPress Events and News’ dashboard widget.

Usage

add_filter('dashboard_primary_title', 'custom_dashboard_primary_title');
function custom_dashboard_primary_title($title) {
  // your custom code here
  return $title;
}

Parameters

  • $title (string) – Title attribute for the widget’s primary link.

More information

See WordPress Developer Resources: dashboard_primary_title

Examples

Modify the primary link title for the ‘WordPress Events and News’ dashboard widget.

add_filter('dashboard_primary_title', 'change_primary_link_title');
function change_primary_link_title($title) {
  $title = 'Custom Title';
  return $title;
}

Add a prefix to the primary link title.

add_filter('dashboard_primary_title', 'add_prefix_to_title');
function add_prefix_to_title($title) {
  $prefix = 'News: ';
  $title = $prefix . $title;
  return $title;
}

Add a suffix to the primary link title.

add_filter('dashboard_primary_title', 'add_suffix_to_title');
function add_suffix_to_title($title) {
  $suffix = ' - Latest Updates';
  $title = $title . $suffix;
  return $title;
}

Convert the primary link title to uppercase.

add_filter('dashboard_primary_title', 'uppercase_primary_link_title');
function uppercase_primary_link_title($title) {
  $title = strtoupper($title);
  return $title;
}

Replace a specific word in the primary link title.

add_filter('dashboard_primary_title', 'replace_word_in_title');
function replace_word_in_title($title) {
  $title = str_replace('WordPress', 'MyWebsite', $title);
  return $title;
}