Cotton Rohrscheib

The Cotton Club Blog & Podcast

  • Home
  • Bio
    • Resume
  • Blog
    • Faith & Family
    • Marketing & Tech
    • Farm & Business
    • Entertainment
    • Health & Wellness
    • Urban Farming
    • Weekend Projects
  • Media
    • Newsletter
    • Photo Galleries
    • Instagram Feed
    • Video Archives
    • Podcasts
    • Music Playlists
  • Books
  • Connect
    • Rohrscheib Capital
    • Disclaimer
    • Privacy Policy
You are here: Home / Marketing & Tech / Wordpress RSS Widget – target=’blank’ fix

WordPress RSS Widget – target=’blank’ fix

March 2, 2009 by Cotton Rohrscheib 16 Comments

If you have ever used RSS Feed Widgets on a website before you will know that one of the biggest aggravations is that the links always open in the same window therefore leaving your website. 

I have posted numerous threads about this in the wordpress forums and haven’t really gotten a lot of response back from the community as to how I could workaround this.  Here are some links to my posts:

  • http://wordpress.org/support/topic/230500
  • http://wordpress.org/support/topic/229767?replies=2

Well, long story short, there is a workaround on this but you are going to have to get your hands dirty and mess with some code and editing the wp-includeswidgets.php file.

You will first want to go to about line #1525 in the code and insert target=’_blank’ in two locations on that file.  Here’s what it will look like once you are done:

<span style="color: #606060">   1:</span> $title = <span style="color: #006080">&quot;&lt;a class='rsswidget' target='_blank' href='$url' title='&quot;</span> . attribute_escape(__(<span style="color: #006080">'Syndicate this content'</span>)) .<span style="color: #006080">&quot;'&gt;&lt;img style='background:orange;color:white;border:none;' width='14' height='14' src='$icon' alt='RSS' /&gt;&lt;/a&gt; &lt;a class='rsswidget' target='_blank' href='$link' title='$desc'&gt;$title&lt;/a&gt;&quot;</span>;

Next, you will go to approximately line #1621 and do the same thing here, adding the target=’_blank’ into the code.  It will look something like this:

<span style="color: #606060">   1:</span> echo <span style="color: #006080">&quot;&lt;li&gt;&lt;a class=&quot;</span>rsswidget<span style="color: #006080">&quot; title=&quot;</span>$desc<span style="color: #006080">&quot; href=&quot;</span>$link<span style="color: #006080">&quot; target=&quot;</span>_blank<span style="color: #006080">&quot;&gt;$title&lt;/a&gt;{$date}{$summary}$author}&lt;/li&gt;&quot;</span>;

Now, as with anything you do to the core wordpress software, you are going to have to make sure you add this back should you ever overwrite the software doing an upgrade, etc.  Why this is not an option on the wordpress cms core functions yet is beyond me…

Share this post on:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pinterest (Opens in new window) Pinterest

Related

About Cotton Rohrscheib

The Cotton Club is a monthly podcast hosted by me, Cotton Rohrscheib. I'm a 52 year old entrepreneur w/ ADHD, OCD (and now AARP) that refuses to grow up as I grow old. I have collaborated and invested in hundreds of projects throughout my career in multiple industries such as; technology, healthcare, and agriculture. I also have 25 years experience in the marketing industry as a co-founder of an award-winning advertising agency. I will undoubtedly cover a wide variety of topics on my podcast while sharing some really crazy stories and situations that I've been fortunate to witness firsthand. I also have a book coming out in 2025 titled, "Mistakes were Made"

Comments

  1. Nick Brewer says

    August 1, 2009 at 3:52 pm

    One way to fix the issue without editing core, would be to search for an “a href” with the class of “rsswidget” using jQuery. Then replace or add the attribute and value for target=”blank”.

    This way you can update your wordpress file without worrying about any core mods. This jQuery solution could be added into the functions.php.

    Reply
  2. Cotton Rohrscheib says

    August 1, 2009 at 4:02 pm

    Thanks, next time I run into this I will check into that.

    Reply
  3. Sabine says

    September 3, 2009 at 9:10 pm

    First off – thanks for this info – works great.

    My only comment is I had to do it to a different file with some slightly different line locations:
    wp-includes/default-widgets.php

    Line 762 – add it twice withing 2 brackets – which are for the RSS title link:

    $title = “<img style='background:orange;color:white;border:none;' width='14' height='14' src='$icon' alt='RSS' /> $title“;

    Line 835 which addresses the link of any articles you may display:

    echo “<li>$title{$date}{$summary}{$author}</li>”;

    Reply
    • Cotton Rohrscheib says

      September 3, 2009 at 9:47 pm

      Okay, thanks for sharing. I posted this on an older version of WordPress than is out now so that might explain the line number differences.

      Reply
  4. Cotton Rohrscheib says

    September 3, 2009 at 9:46 pm

    Reply
  5. Dave Yates says

    October 18, 2009 at 1:21 pm

    Thanks for this, it did the trick – one mod from Sabine's comment.

    Make the mods to Lines 728 and 837 on wp-includes/default-widgets.php

    Modify these lines as below:

    Line 728:
    – –
    $title = “<img style='background:orange;color:white;border:none;' width='14' height='14' src='$icon' alt='RSS' /> $title“;

    – –

    Line 837

    – –
    echo “<li>$title{$date}{$summary}{$author}</li>”;

    – –

    Reply
    • Cotton Rohrscheib says

      October 23, 2009 at 3:12 pm

      Thanks for the update.

      Reply
  6. Brad says

    December 2, 2009 at 9:51 pm

    Thank you for the widget fix

    Reply
  7. Roman says

    March 22, 2010 at 12:46 pm

    Thanks for your help :o)

    Reply
  8. Visitor says

    October 5, 2010 at 8:04 am

    Hi,
    with wordpress 3.1 I had to going to 'default-widgets.php'
    line 740 + 861
    hope this information helps to save time for users 🙂

    Reply
    • Cotton Rohrscheib says

      October 15, 2010 at 6:17 pm

      Awesome, thanks for the information. I had wondered how all of this related to 3.1.

      Reply
  9. jdonlon says

    November 20, 2010 at 2:35 am

    Tremendous…thanks so much!

    Reply
    • Cotton Rohrscheib says

      November 20, 2010 at 4:25 am

      No problem. It’s surprising how popular this post continues to be.

      Reply
  10. Cotton Rohrscheib says

    March 8, 2011 at 2:45 pm

    I can’t think of one right now, but I will do some research.

    Reply

Trackbacks

  1. RSS Feed Widget Med Target=_BLANK !? - Webforumet.no says:
    November 30, 2009 at 5:58 pm

    […] […]

    Reply

Please Drop Your Questions or CommentsCancel reply

Let’s Connect

  • Email
  • Facebook
  • Instagram
  • LinkedIn
  • Twitter

Recent Updates

  • EP:032 – Cotton Rohrscheib & Diana DeHart
  • Challenges & Opportunities Going into 2025
  • Find us at the 2025 Arkansas Women in Agriculture Conference in Hot Springs, Arkansas
  • Be Sure to Checkout FBN’s Farmers First™  Crop Nutrition & Adjuvant Lineup for 2025
  • What we all need in Dark Times…

Blog Categories

  • Blog (419)
  • Entertainment (376)
  • Faith & Family (147)
  • Farm & Business (288)
  • Health & Wellness (33)
  • Marketing & Tech (584)
  • Podcasts (31)
  • Urban Farming (20)
  • Weekend Projects (1)

Listen & Subscribe

Blog Archives

Join the Cotton Club!

 

Content Copyright: 2001-2025
Cotton Rohrscheib | Rohrscheib Capital