Where to find Malcolm Coles, reviews, and tips on how to do things I couldn’t do.

malcolm coles


Avoid duplicate content with paged comments in wordpress 5

Posted on January 17, 2009 by Malcolm Coles

I've written before about the problem of duplicate content problems with wordpress comment pagination.

After reading this post about using the excerpt on pages 2 or higher of the comment loop, I discovered the variable that will give a similar solution to that for duplicate content in pages 2 or higher of the wordpress loop.

So use the PHP below, and you won't have duplicate content problems if you have paginated comments. Update: And see Christian's comment at the end to see it not only in action, but how he's edited All in One SEO Pack to get it to work with that as well. Blimey!

Use cpage instead of paged

To avoid duplicate content problems, you need a different title and a different meta description. The easiest way to do this is to add 'Page X' into the title and meta description of the blog post.

Here's the code to do this - add it into your theme's header just before the closing </title> tag:

<?php if ( $cpage < 2 ) {}
else { echo (' - comment page '); echo ($cpage);}
?>

Do something similar with the code that generates your meta description.

What the code does

If you're on page two or higher of paginated comments, it adds ' - comment page X' (where X is the comment page) to the end of the title (which is the heading that appears in google).

You can use something similar in your meta description code.

Where can I see it working?

It was working here when I tried it. As the most comments I have on a post is 19 so far,  however, I don't actually paginate my comments yet (it's set to the default of 50 - I changed it to 2 to test it, but i couldn't really leave it like that!!)

Perhaps someone with a lot of comments could use it and provide a link so we can see it working ... Update: See Christian's comment for someone who has done just that.

You might also like
  1. Adding page numbers: How to avoid duplicate titles and meta descriptions in pages 2 and higher of Wordpress category and tag pages
  2. Wordpress comment pagination & duplicate content
  3. Can you use rel = canonical to fix duplicate comment problems caused by comment pagination in wordpress?
  4. Unique meta description and meta keyword tags in your Wordpress themes
  5. Wordpress and smart/curly quotes: turning them off

You should follow me on Twitter.

5 Responses to “Avoid duplicate content with paged comments in wordpress”

  1. Hi Malcolm,
    I commented on your comment: Thanks a lot for this post, it's working fantastic on my site!

  2. Kretzschmar says:

    I think there is some room for optimiziation.

    1) echo $cpage; ?>

  3. Rudi says:

    I have just followed your suggestion and now I am waiting is still Google detect duplicate content.

Leave a Reply

All comments are moderated. Comments that include URLs and which just say 'Nice post' or similar won't be published, but thanks for the sentiment.

Trackbacks/Pingbacks
  1. How to: Avoid duplicate content in paged comments
Find more posts like this



↑ Top