the_title_rss()
outputs its value straight away so it can’t be used in a function like that, you would have to use get_the_title_rss()
Or alternatively the_title_rss() has a filter we can hook in to and return your shortened title is possible. (You would add this to your functions.php)
function gg_short_title_rss($title)
{
// This can return false, so check there is something
$short_title = substr($title, 0, strpos($title, ' –'));
if ($short_title) {
return $short_title;
}
// Else just return the normal title
return $title;
}
add_filter('the_title_rss', 'gg_short_title_rss', 10, 1);