I’ve recently come across a slight problem with one of my clients whereby they wanted the RSS feed widget to open all incoming links in a new window. And why wouldn’t they? Especially if they’re external RSS feeds that are being parsed.
We could have used the Better RSS plugin, but until I knew that I had to poke around and see whether it was possible. Of course it was. Here’s what you need to do.
Open WordPress RSS Feed using an additional target=”_blank” command
Find around line 898 of defaults-widgets.php in your wp-includes folder.
Replace:
if ( $link == '' ) {
echo "<li>$title{$date}{$summary}{$author}</li>";
} else {
echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>";
}
With:
if ( $link == '' ) {
echo "<li>$title{$date}{$summary}{$author}</li>";
} else {
echo "<li><a class='rsswidget' target='_blank' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>";
}
And you’re done! Of course, future WordPress updates could break this so it might be best to either create a function or use an alternative, but I thought I’d add it just for reference.
Warren’s article and suggestion worked! Fast and easy, the way it should be! Problem is, most people had a very long and drawn out explanation on how to open a new window with an RSS Feed in WordPress?.It would be great if most people even knew how to write an article or post, let alone explaining how to do something!
Thank you Warren!!