The documentation specifies:

type (string) (optional) Controls format of the returned value. Possible values are:

  • 'plain' - A string with the links separated by a newline character.
  • 'array' - An array of the paginated link list to offer full control of display.

In order to add twitter bootstrap pagination styling to the wordpress comments pagination, I want to have the return be an array.

When I add $args to the call, i get no return.

My Code:

<ol class="commentlist" style="list-style: none;">
    <?php wp_list_comments('type=comment&callback=advanced_comment'); ?>
<div class="clear"></div>
<div class="pagination">
    $args = array(
    'base'         => '%_%',
    'format'       => '?page=%#%',
    'total'        => 1,
    'current'      => 0,
    'show_all'     => False,
    'end_size'     => 1,
    'mid_size'     => 2,
    'prev_next'    => True,
    'prev_text'    => __('« Previous'),
    'next_text'    => __('Next »'),
    'type'         => 'array',
    'add_args'     => False,
    'add_fragment' => ''

Is this because I am using a custom callback for wp_list_comments?

My advanced_comment() callback:

function delete_comment_link($id)
    if (current_user_can('edit_post'))
    echo '<a href="'.admin_url("comment.php?action=cdc&c=$id").'" class="btn btn-default">del</a> ';
    echo '<a href="'.admin_url("comment.php?action=cdc&dt=spam&c=$id").'" class="btn btn-default">spam</a>';
function advanced_comment($comment, $args, $depth)
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
    <div class="panel panel-default">
        <div class="panel-heading"><?php comment_author(); ?> says: <?php echo substr(get_comment_excerpt(), 0, 25) . "..."; ?></div>
        <div class="panel-body">
            <div class="col-md-1">
            <?php echo get_avatar($comment,$size='75',$default='<path_to_url>' ); ?>
            <?php if ($comment->comment_approved == '0') : ?>
            <em><?php _e('Your comment is awaiting moderation.') ?></em>
            <br />
            <?php endif; ?>

            <div class="comment-text col-md-10">
            <div class="comment-meta">
                <?php echo get_comment_author_link($comment->ID); ?>
                <?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?><?php edit_comment_link(__('(Edit)'),'  ','') ?>
                <?php comment_text() ?>

            <div class="btn-group float-right">
            <?php echo get_comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => "<span class='btn btn-default'>", 'after' => '</span>'))) ?>
            <?php delete_comment_link(get_comment_ID()); ?>
            <div class="clear"></div>

Please note: paginate_comments_links() works fine if I do not pass it $args.


<ul class="pagination">
        $pages = paginate_comments_links( array( 'echo' => false, 'type' => 'array' ) );
        foreach($pages as $page)
        echo "<li>" . $page . "</li>";

1 Answer 1


The first thing to say would be, you can't say you haven't been warned - see codex page paginate_comments_links(), section »Defaults«:

These arguments are mostly to make the call of paginate_links() work, so be careful if you change them.

It's true, paginate_comments_links() is pretty much just a already customized version for comments of paginate_links(), with those defaults to make this work:

  • 'base' => add_query_arg( 'cpage', '%#%' ),
  • 'format' => ,
  • 'total' => $max_page,
  • 'current' => $page,
  • 'echo' => true,
  • 'add_fragment' => '#comments'

What you're doing is overriding the necessary - hence the warning - defaults of paginate_comment_links() with the defaults of paginate_links(), which leads to the comment links not working anymore. If I'm seeing it correctly the only parameter you want to change is type, so this is the only one you have to pass.

Like this:

$args = array( 
    'type' => 'list' 
paginate_comments_links( $args );


paginate_comments_links( array( 'type' => 'list' ) );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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