Display all comments for a WordPress blog on a single page?

What I need – The code to perform the following:

I am trying to setup a WordPress template that will display all the comments that have been posted to my blog. How do I pull all comments and have all the same formatting that is applied to comments under a single post? Such as the formatting that occurs when comments are displayed using the comments.php template.

Read More

Note I want to pull all the comments from my blog to a single page. I still want the comment pagination but instead of having 20 comments under post #1, 20 under post #2, etc. I want to have all 40 show up at one time on one page.

Related posts

Leave a Reply

1 comment

  1. You want to use the get_comments() function.

    <?php foreach (get_comments() as $comment): ?>
    <div><?php echo $comment->comment_author; ?> said: "<?php echo $comment->comment_content; ?>".</div>
    <?php endforeach; ?>
    

    See also the apply_filters() function to apply comment output filters to specific fields.

    <?php echo apply_filters('comment_text', $comment->comment_content); ?>
    

    EDIT:

    For pagination, you can use the offset and number parameters of the get_comments() arguments:

    <?php 
        $args = array(
            'number'=>20,
            'offset'=>0,
            'status'=>'approve',
        );
        foreach (get_comments($args) as $comment) {
            // ...
        }
    ?>