Using WordPress ‘get_wp_title_rss’ PHP filter

The get_wp_title_rss WordPress PHP filter modifies the blog title for use as the feed title.

Usage

add_filter('get_wp_title_rss', 'your_function_name', 10, 2);
function your_function_name($title, $deprecated) {
    // your custom code here
    return $title;
}

Parameters

  • $title (string) – The current blog title.
  • $deprecated (string) – Unused.

More information

See WordPress Developer Resources: get_wp_title_rss

Examples

Append custom text to the feed title

Modify the blog title in the RSS feed by appending custom text.

add_filter('get_wp_title_rss', 'append_custom_text', 10, 2);
function append_custom_text($title, $deprecated) {
    $title .= ' - Custom Text';
    return $title;
}

Prepend site name to the feed title

Add the site name before the blog title in the RSS feed.

add_filter('get_wp_title_rss', 'prepend_site_name', 10, 2);
function prepend_site_name($title, $deprecated) {
    $site_name = get_bloginfo('name');
    $title = $site_name . ' - ' . $title;
    return $title;
}

Replace specific text in the feed title

Replace specific text in the blog title for the RSS feed.

add_filter('get_wp_title_rss', 'replace_specific_text', 10, 2);
function replace_specific_text($title, $deprecated) {
    $title = str_replace('Old Text', 'New Text', $title);
    return $title;
}

Uppercase the feed title

Change the blog title in the RSS feed to uppercase.

add_filter('get_wp_title_rss', 'uppercase_feed_title', 10, 2);
function uppercase_feed_title($title, $deprecated) {
    $title = strtoupper($title);
    return $title;
}

Add post count to the feed title

Add the total number of published posts to the blog title in the RSS feed.

add_filter('get_wp_title_rss', 'add_post_count', 10, 2);
function add_post_count($title, $deprecated) {
    $post_count = wp_count_posts()->publish;
    $title .= ' (' . $post_count . ' Posts)';
    return $title;
}