Mobile app version of vmapp.org
Login or Join
Megan663

: Add rel=nofollow to all links in rss feed i wish to add a rel=nofollow in all links from an rss feed, including links in item description $rss = new DOMDocument(); $rss->load($xml); $feed =

@Megan663

Posted in: #Php #Rss

i wish to add a rel=nofollow in all links from an rss feed, including links in item description

$rss = new DOMDocument();
$rss->load($xml);
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed, $item);
}
$limit = count($feed);

for($x=0;$x<$limit;$x++) {
$title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
$link = $feed[$x]['link'];
$description = $feed[$x]['desc'];
$date = date('l F d, Y', strtotime($feed[$x]['date']));
echo '<p><strong><a rel="nofollow" href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />';
echo '<small><em>Posted on '.$date.'</em></small></p>';
echo '<p>'.$description.'</p>';
}

10.04% popularity Vote Up Vote Down


Login to follow query

More posts by @Megan663

4 Comments

Sorted by latest first Latest Oldest Best

 

@Angie530

This may not always be positive SEO. If your source RSS contains link anchors that do not relate to your site content, Google cannot differentiate between those anchors and the links elsewhere on the page. This will cause a negative effect from an SEO perspective. Some people wish to have nofollows in all their RSS feed links - in fact WordPress RSS (and other CMS too) defaults to all nofollow links.

The difficulty is that many people do not have control over the formation of feeds they display because they come from a 3rd party; a solution for creating nofollows across a complete feed is actually in demand - I know this because I am support manager for the FeedWind RSS widget. We have been asked by users how to implement nofollow across a feed. So far the only solution we have identified is to create code that will parse feed content.

10% popularity Vote Up Vote Down


 

@Gonzalez347

The only links that could take rel='nofollow' are ones within the CDATA in the body of the syndicated content. A quick and dirty hack would be to do a string replace for <a with <a rel='nofollow' when outputting the content of the articles. If they already have nofollow somewhere then you are going to make some ugly HTML.

As others have pointed out RSS specs do not allow for microformats like nofollow. Additionally you are depriving yourself of some solid SEO.

10% popularity Vote Up Vote Down


 

@LarsenBagley505

I do like creativity but, I'm afraid the idea just doesn't make sense to me.

When you set up an RSS feed, you want the links to actually point to your site, not apply a nofollow to them. Also, links that have nofollow applied will cause search engine robots not to scan them and if the resulting pages are very high quality with advertisements in your name, then you'll likely lose out on income.

Think of an RSS feed as a special version of a site map. If there are links you want to hide, then you shouldn't have the script include those links in the first place.

10% popularity Vote Up Vote Down


 

@Ann8826881

RSS does not allow for nofollow. RSS is not HTML but a simple mark-up for Really Simple Syndication.

The documentation for RSS 2.0 can be found here: validator.w3.org/feed/docs/rss2.html It will contain much of the latest information you need.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme