| Welcome to WebmasterWorld Guest from 22.214.171.124 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|Can I use CSS to add rel="nofollow"?|
| 1:46 am on Mar 18, 2012 (gmt 0)|
More precisely: I have an RSS news feed on my site. I can control its appearance with CSS. Can I use CSS to automatically add the rel="nofollow" attribute to all links in that feed?
| 2:47 am on Mar 18, 2012 (gmt 0)|
No. CSS is all about styling.
| 2:54 am on Mar 18, 2012 (gmt 0)|
Hmmm maybe php, then? If my current rss php is
|<?php readfile('http://my_feed')?> |
Is there any code I can add to this, so that <a> tags are added the rel="nofollow" attribute? Something along these lines:
|$('#a').attr( 'rel', 'nofollow' ); |
| 5:11 am on Apr 19, 2012 (gmt 0)|
You could do it with preg_replace/match using regex. I don't think you would want to be using jQuery to be telling search engines that you distrust a link.
| 6:22 am on Apr 19, 2012 (gmt 0)|
Actually I have got help from the excellent guys of Rssinclude in the meantime, and I now have a script that adds nofollow to all news links.
It's only natural to distrust news sites; isn't it? :-)
| 4:37 pm on Apr 19, 2012 (gmt 0)|
The only solid solution is the one suggested above - grab the feed content, use preg_replace to add nofollow to the link, then output the modified content.
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved