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?
1 Answer
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="https://wordpress.stackexchange.com/questions/95362/%s" />\n', $link );
}
remove_action( 'wp_head', 'rel_canonical' );
add_action( 'wp_head', 'comment_rel_canonical' );