Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

With comment pagination, Google doesn't index the older pages and comments become essentially lost to searches.

Is there a way to let search engines crawl paginated comments, perhaps by generating a sitemap file that includes all paginated comments?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The reason of why Google doesn't index paginated comments is because of an issue with the canonical URL in your header. You can learn more about the reason behind this in a comprehensive question that I posted earlier. There is an excellent solution posted there for paginated post pages.

Now, for Google to index comment pagination, bungeshea posted an answer for a while ago when he (by accident) solved this when actually aiming to fix indexing for post pagination.

Luckily, I saved that code:

function comment_rel_canonical() {

    if ( ! is_singular() )
        return;

    global $wp_the_query;

    if ( ! $id = $wp_the_query->get_queried_object_id() )
        return;

    $link = get_permalink( $id );

    if ( $page = get_query_var('cpage') )
        $link = get_comments_pagenum_link( $page );

    if ( $paged = get_query_var( 'paged' ) )
        $link = add_query_arg( 'paged', get_query_var( 'paged' ), $link );

    printf ( '<link rel="canonical" href="%s" />\n', $link );
}

remove_action( 'wp_head', 'rel_canonical' );
add_action( 'wp_head', 'comment_rel_canonical' );
share|improve this answer
1  
You can always link to a single state of a post. –  toscho Apr 11 '13 at 5:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.