WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to create a custom comments page with pagination.

I have non-hierarchical custom type "apartments".

It makes urls like:

/apartments/ - for acrhive
/apartments/%id%/ - for post page
/apartments/%id%/comments-page-X/ - for comments (X is some number)

How do I create page /apartments/%id%/questions/ for comments? And remove /apartments/%id%/comments-page-X/ if possible.

I would like to make this url structure for comments:

/apartments/%id%/questions/ - first page of the comments
/apartments/%id%/questions/page/X/ - pagination for comments (X is some number)

What is the solution?

share|improve this question
you can do that with paginate_comments_links() and setting your base to questions, codex.wordpress.org/Function_Reference/paginate_comments_links and then add your rewrite rule. – Bainternet Apr 18 '11 at 3:13
can you give a coded example? I will accept your answer if it works. – ilovewordpress Apr 18 '11 at 11:13
up vote 1 down vote accepted
    $args = array('post_id'=>get_the_ID(), 'status'=> 'approve');
    $all_comm = get_comments($args);
    $per_page = get_option("comments_per_page");
    $per_page = 4;
    $cpage = get_query_var("cpage");
    $cpage = 1;
    if(round(count($all_comm)/$per_page) == 0)
    $total = 1;
    $total = round(count($all_comm)/$per_page);
    $args_comments = array(
        'base' => add_query_arg( 'cpage', '%#%' ),
        'format' => "",
        'total' => $total,
        'current' => $cpage,
        'echo' => false,
        'add_fragment' => '#reviews'
    $pagi_comments = paginate_comments_links($args_comments);
    $args = array('post_id'=>get_the_ID(), 'status'=> 'approve', 'number' => $per_page, 'offset' => $per_page*($cpage-1));
    $all_comm = get_comments($args);
    foreach($all_comm as $as){ print_r($as); }
    echo $pagi_comments;

I hope it helps lot to you.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.