How to Determine Paged Comments in WordPressWordPress 2.7 added paged comments however you may want to prevent search engines from indexing extra pages to prevent duplicate content

WordPress 2.7 introduced paged comments out of the box. However, you may want to block search engines from indexing these pages to prevent duplicate content. You may also wish to determine if a user is viewing a paged comment.
The new update to WordPress will allow your comments to be paged, that is, show comments 1-50 on page 1, 51 - 100 on page 2, etc, but it will also have the effect of duplicating your content on many pages. This can potentially harm your website's SEO. However, by preventing search engines from indexing these pages using the 'robots=nofollow' meta attribute, you can take control and avoid falling foul of the duplicate content filter. This simple function to identify a comment page and a little change to the header can save you from potential penalties by Google in the forthcoming Panda update.
The function for comment paged detection is straightforward and should be placed in the functions.php in your themes folder. It's a simple check that looks for 'comment-page' in the URL, making it easy for you to implement and manage.
Detect Paged Comments in WordPress
function is_comments_paged()
{
$pos = strpos($_SERVER['REQUEST_URI'], "comment-page");
if ($pos === false)
{
return false;
}
else
{
return true;
}
}
Implementing the 'comment-page' detection in the URL is straightforward. It's a simple check that looks for 'comment-page' in the URL.
In your header, you must add (or modify if you have a similar section) this code. This code is crucial as it prevents the indexing of paged comments. I have added the above function call on a different line for clarity, but you can merge it with the first if statement.
<?php
if((is_home() || is_single() || is_category() || is_page()) && (!is_paged()))
{
if (is_comments_paged())
echo ' <meta name="robots" content="noindex,follow" />';
else
echo ' <meta name="robots" content="index,follow" />';
}
else
{
echo ' <meta name="robots" content="noindex,follow" />';
}
?>