Support » Fixing WordPress » RSS Widget – How to open links in new window?

  • Hello,

    I see that there is a default RSS widget inside of WordPress, but the only thing I can’t figure out is how to get the links to open up in a new tab or window. I’d prefer not to have to use a plugin just for this as the default RSS widget is enough for me at this time.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,

    To open the WordPress RSS link in a new window, follow the steps below:-

    Login to your WordPress admin panel, Appearance -> Editor
    Click on header.php at the right sidebar
    Add the content below between the head tag

    <script type="text/javascript">
    	jQuery('a.rsswidget').click(function() {
    	    jQuery(this).attr('target', '_blank');
    	});
    </script>;

    * make sure you have jquery loaded
    Once done, update the file and you may refresh your front page.

    Note: As I don’t have a link to your site, the class i.e. a.rsswidget may be different.

    Thanks.

    Hi @dccmike,

    You can follow these 2 steps:

    1. Open the file wp-includes/default-widgets.php

    2. Go to line 858 and you will see it has the following content: (note that if you copy-paste the code, you should correct the single and double quotes)

    echo “<li><a class=’rsswidget’ href=’$link’ title=’$desc’>$title</a>{$date}{$summary}{$author}</li>”;

    What you need to do now is to add target='_blank' to the tag and it’s done. After adding this line, you will have the following form:

    echo “<li><a class='rsswidget' href='$link' target='_blank' title='$desc'>$title</a>{$date}{$summary}{$author}</ li>”;

    Note that this is action is applied for version 3.1.2. With other versions, there may be differences. To perform on these versions, please search in that file with the keyword ‘rsswidget’ to find the tag which is similar to the above one and add target= '_blank' in.

    Let me know if my answer can help you resolve your issue.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.