WordPress recent comments link not working
I recently upgraded my blog to the latest version – WordPress 2.7 and have found a small bug which I’m not entirely sure wasn’t there before, but I only noticed it today after the upgrade.
I use the Recent Comment widget on the sidebar to display recent comments on my posts in the form of “{authorLink} On {postLink}”. I noticed that the author link (links to website of whoever posted a comment on one of my posts) didn’t seem to work in all browsers accept Google Chrome.
On further investigation into the source of the page, I realised that for some reason the link generated was urlEncoded and not formated right.
e.g ‘http://www.example.com%27%20rel%3D%27external%20nofollow’
instead of “http://www.example.com” rel=”external nofollow”
After a few minutes of debugging and digging around through the wordpress pages. I eventually found the source of the problem located on line 148 in category-template.php in the wp-includes folder.
$return = “<a href=’$url’ rel=’external nofollow’ class=’url’>$author</a>”;
I simply changed the line above to
$return = “<a href=”$url” rel=”external nofollow” class=”url”>$author</a>”;
and that sorted out the format of the output string and PRESTO the links work again.
* UPDATE – 9th February 2009
Just a heads up on this post.
Some WP users have reported that they’ve found the line in question in “comment-template.php” and not in “category-template.php”. So if you cant find it in one of them, it’s most likely in the other.
Deviant Art
LinkedIn
RSS feed
Twitter
David Steadson
Thanks! Just noticed this same problem myself, however the line was in comment-template.php, not category-template.php
Vern at AimforAwesome
That’s awesome! I’m glad you found it. You realize you are the ONLY person in google to have had this error and did something about it (in English)?
The other was spanish I believe. Thanks SO much for your help…
Vern at AimforAwesome
well, didn’t work – Didn’t find it in category template. Found it in comment template. Replaced the line- it broke the whole blog. Copied over original from WP install (2.7) and blog works – links still broken. Hmm…… bummer!
henry
Hi Vern, do you have a link to your blog where you have the recent comments widget activated so I can have a look at the source of your page and see if I can help you sort it out.
greg
I was able to fix this by just deleting
rel=’external nofollow’ class=’url’
it doesn’t open in a new window, but it does open.
koma
hi. i found you searching google with “comments url doesn`t work”. i don`t know where to look, please help me. some of my commenters links doesn`t work at all, others are broken because of rel=nofollow item newly added i presume.
henry
Hi, I could try be of some assistance or at least guide you the right way. Do you have an example page up with this problem that I could have a look at and try figure out where your links are malformed?
mike
Just noticed this on the company blog! Cheers for the heads up. Hopefully someone will be able to get in and get this issue sorted. Wish I’d noticed sooner that they were using literal quotes by mistake in the code.
ankara nakliyat
very nice blog
thank you