
Duplicate content is one of the most discussed topics in terms of SEO. Happilly, with the new rel=’canonical’ attribute, you can now reduce risks of duplicate content. Here is how to implement it for your comments pages, on your WordPress blog.

Duplicate content is one of the most discussed topics in terms of SEO. Happilly, with the new rel=’canonical’ attribute, you can now reduce risks of duplicate content. Here is how to implement it for your comments pages, on your WordPress blog.
Simply paste the following code on your function.php file:
function canonical_for_comments() {
global $cpage, $post;
if ( $cpage > 1 ) :
echo "\n";
echo "<link rel='canonical' href='";
echo get_permalink( $post->ID );
echo "' />\n";
endif;
}
add_action( 'wp_head', 'canonical_for_comments' );
Thanks to I like WordPress for the useful tip!
24 Responses
I didn’t know what rel=canonical was, so I had to look it up. Here’s a great — and witty — quickie explanation by Conversation Marketing: http://www.conversationmarketing.com/2009/02/3-reasons-to-use-rel-canonical.htm
Hi,
I landed in your blog while searching for “Canonical tag”.
I used it in my websites but had no idea how to imlement it in WP.
Finally I got the function. Thanks a lot.
Hi, I think All in one SEO pack plugin and Platinum SEO pack can handle it.
haha, nice i was looking for this.
great post and keep up the good work.
@ Rismaka : maybe that for someone who didn’t use that plugin
Yeah, its sucks when people steel content.
Wow. This wonderful.
for what canoncial is ?
Hm, I tried your snippet but it didn’t work…
Thanks for the code.
Actually I already had canonicals in place. I just hoped this snippet would maybe take in consideration the comment page (for those who have paged comments) you´re on. At the moment the post url and and all comment sub-pages still share the same canonical url which I´m sure is still a duplicate content issue. Is there a way to include the sub-comment page into the canonical tag?
Trackbacks: