Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8568137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:02:30+00:00 2026-06-11T18:02:30+00:00

I want to build a page that would display all comments , regardless of

  • 0

I want to build a page that would display all comments, regardless of which post they’re attached to. I also want that page to be paginated, since it’ll potentially have 10,000+ comments.


I’m not sure how to go about it, but here are some of the functions I’ve studied so far:

  1. get_comments – If no post_id is passed in, it’ll return all comments. However, I don’t see a way to paginate these (there are offset and number options to fiddle with, but that’s very tedious to do manually).

  2. wp_list_comments – The documentation on this is pretty bad, but the source code suggests that we can loop over all comments if used in conjunction with get_comments, by passing in the get_comments array as a second argument. This however would still use get_comments to actually… well, get the comments, and there seems to be no way to paginate that.

  3. previous_comments_link & next_comments_link – These seem to only work in conjunction with wp_list_comments (with no second argument).

  4. paginate_comments_links – Also looks like it only works with wp_list_comments (with no second argument).


What I’ve tried:

  1. Simply using the number argument in get_comments:

    $comments = get_comments(array(
        'status'    => 'approve',
        'number'    => '2'
    ));
    
    wp_list_comments(array(
        'callback' => 'my_rendering_function'
    ), $comments);
    
    paginate_comments_links();
    

    This does not display any pagination links.

  2. The method suggested here: Display latest comments on page with pagination

    $comments = get_comments(array(
        'status' => 'approve'
    ));
    
    wp_list_comments('per_page=2', $comments);
    
    paginate_comments_links();
    

    This doesn’t either work (it shows the first 2 comments, but no pagination). Also, I cringe at get_comments loading all comments into memory.


Question:

How can I paginate all comments?


P.S. I’m using WordPress 3.4.1 & PHP 5.3.2.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:02:31+00:00Added an answer on June 11, 2026 at 6:02 pm

    If your planning to build your own pagination, you will need to know the total number of comments your going to be using and thus your going to have to load all comments.

    I’ve built below what i would use, let me know if it helps.

    #Config here.
    define('DEFAULT_COMMENTS_PER_PAGE',100);
    
    $page = (int) (!isset($_REQUEST["page"]) ? 1 : $_REQUEST["page"]);
    $limit = DEFAULT_COMMENTS_PER_PAGE;
    $offset = ($page * $limit) - $limit;
    $param = array(
        'status'=>'approve',
        'offset'=>$offset,
        'number'=>$limit,
    );
    $total_comments = get_comments(array('status'=>'approve'));
    $pages = ceil(count($total_comments)/DEFAULT_COMMENTS_PER_PAGE);
    $comments = get_comments($param);
    foreach($comments as $comment) {
        // ECHO THE AUTHOR AND COMMENT
        echo("<strong>{$comment->comment_author}</strong> - {$comment->comment_content}");
    }
    $args = array(
    'base'         => 'https://example.com/all-comments/%_%',
    'format'       => '?page=%#%',
    'total'        => $pages,
    'current'      => $page,
    'show_all'     => False,
    'end_size'     => 1,
    'mid_size'     => 2,
    'prev_next'    => True,
    'prev_text'    => __('&laquo; Previous'),
    'next_text'    => __('Next &raquo;'),
    'type'         => 'plain');
    // ECHO THE PAGENATION 
    echo paginate_links( $args );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to build a form_tag that will allow me to post a new
I want to build a python program that deletes all the photos from my
I want to build a Web page (in Asp.Net) containing a Dynamic Menu where
I want to build a webapplication with a Single Page Interface, using ASP.NET MVC.
I want build a sketch pad app on iPhone, I assume that this type
I want to build flash application that can detect the user eyes color and
I have an Activity that has all the display elements added dynamically. Theres no
I want to build an image scroller that works like google map. When the
I want to think of a way to display and query comments. Each comment
I'm looking to build a Silverlight application and want to display a Tag Cloud

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.