How to Paginate WordPress Comments

In some cases when you have a lot of comments on a post, you want to split them into pages so user don’t need to scroll a lot. Lot of blogs or websites will never need this, but as I said in some cases this will be needed.

To set it up first go to Settings / Discussion and change comment option like bellow:

Enable check box – Enable threaded (nested) comments “5” levels deep.
Enable check box – Break comments into pages with “7” top level comments per page and the “last” page displayed by default.
Comments should be displayed with the “newer” comments at the top of each page.

So now everything works, your comments are paginated and click on older comments link will add “/comment-page-2#comments” to the end of your URL and get you to second page. All this is good but there is one slight problem with page Title Meta Tag, which will be the same for every comment page. This is no good at all since it will downgrade Google SEO and get you Duplicated Title Tags Warning.

To fix this navigate to your theme folder inside wp-content/themes/your-theme or even better your-theme-child and edit header.php file. Find this line: (it could be different on different themes)

<title><?php wp_title( '|', true, 'right' ); ?></title>

and change it to something like this:

<?php wp_title( '|', true, 'right' ); 
$page_comment = get_query_var('cpage');
if ($page_comment > 0) {echo ' | Page '.$page_comment;}?>

That should be it, your post comment pages will now should be SEO Friendly and shorter to scroll, therefore more user friendly.

One thought on “How to Paginate WordPress Comments

Leave a Reply

Your email address will not be published. Required fields are marked *