Using WordPress ‘get_wp_title_rss()’ PHP function

The get_wp_title_rss WordPress PHP function retrieves the blog title for the feed title.

Usage

get_wp_title_rss($deprecated);

Example:

$title = get_wp_title_rss();
echo $title; // Output: "Your Blog Title"

Parameters

  • $deprecated (string) (optional) – Unused. Default: ‘–’

More information

See WordPress Developer Resources: get_wp_title_rss

Examples

Basic usage

Retrieve the blog title for the feed title and display it.

$title = get_wp_title_rss();
echo $title;

Add a custom prefix to the feed title

Retrieve the blog title for the feed title, add a custom prefix, and display it.

$prefix = 'Latest Posts: ';
$title = get_wp_title_rss();
echo $prefix . $title;

Add a custom suffix to the feed title

Retrieve the blog title for the feed title, add a custom suffix, and display it.

$suffix = ' - Your Source for News';
$title = get_wp_title_rss();
echo $title . $suffix;

Modify the feed title using a filter

Add a filter to modify the blog title for the feed title.

function modify_feed_title($title) {
  return 'Modified: ' . $title;
}
add_filter('get_wp_title_rss', 'modify_feed_title');

$title = get_wp_title_rss();
echo $title;

Remove a filter from the feed title

Remove a filter that modifies the blog title for the feed title.

function modify_feed_title($title) {
  return 'Modified: ' . $title;
}
add_filter('get_wp_title_rss', 'modify_feed_title');

$title = get_wp_title_rss();
echo $title; // Output: "Modified: Your Blog Title"

remove_filter('get_wp_title_rss', 'modify_feed_title');
$title = get_wp_title_rss();
echo $title; // Output: "Your Blog Title"