For some odd reason, I can’t seem to make the pagination work for comments.
$args = array( 'post_type' => 'products', 'status' => 'approve', ); // The Query $comments_query = new WP_Comment_Query; $comments = $comments_query->query( $args ); // Comment Loop if ( $comments ) { foreach ( $comments as $comment ) { echo '<p>' . $comment->comment_content . '</p>'; } } else { echo 'No comments found.'; }
I also tried to use
wp_list_comments
and thenpaginate_comments_links();
but the pagination is still not visible even though there’s plenty of comments it should show.What else should I add so that the pagination works? I do know I should use the
offset
andnumber
parameter. But don’t know how.
Any help is much appreciated.Edit: Not sure if it helps, but the comments aren’t being displayed on a post or post_type. I’m placing the comments on a seperated page.
Answer
Have you tried paginate_comments_links();?
<div class="navigation">
<?php paginate_comments_links(); ?>
</div>
Attribution
Source : Link , Question Author : kiarashi , Answer Author : Steve