paginate_comments_links( string|array $args = array() ): void|string|array

Displays or retrieves pagination links for the comments on the current post.


See also


Optional args. See paginate_links() .
More Arguments from paginate_links( … $args )Array or string of arguments for generating paginated links for archives.
  • base string
    Base of the paginated url.
  • format string
    Format for the pagination structure.
  • total int
    The total amount of pages. Default is the value WP_Query‘s max_num_pages or 1.
  • current int
    The current page number. Default is 'paged' query var or 1.
  • aria_current string
    The value for the aria-current attribute. Possible values are 'page', 'step', 'location', 'date', 'time', 'true', 'false'. Default is 'page'.
  • show_all bool
    Whether to show all pages. Default false.
  • end_size int
    How many numbers on either the start and the end list edges.
    Default 1.
  • mid_size int
    How many numbers to either side of the current pages. Default 2.
  • prev_next bool
    Whether to include the previous and next links in the list. Default true.
  • prev_text string
    The previous page text. Default ‘« Previous’.
  • next_text string
    The next page text. Default ‘Next »’.
  • type string
    Controls format of the returned value. Possible values are 'plain', 'array' and 'list'. Default is 'plain'.
  • add_args array
    An array of query args to add. Default false.
  • add_fragment string
    A string to append to each link.
  • before_page_number string
    A string to appear before the page number.
  • after_page_number string
    A string to append after the page number.



void|string|array Void if 'echo' argument is true and 'type' is not an array, or if the query is not for an existing single post of any post type.
Otherwise, markup for comment page links or array of comment page links, depending on 'type' argument.

More Information


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

Arguments passed in are merged to the defaults, via wp_parse_args() .
These arguments are mostly to make the call of paginate_links() work, so be careful if you change them.


function paginate_comments_links( $args = array() ) {
	global $wp_rewrite;

	if ( ! is_singular() ) {

	$page = get_query_var( 'cpage' );
	if ( ! $page ) {
		$page = 1;
	$max_page = get_comment_pages_count();
	$defaults = array(
		'base'         => add_query_arg( 'cpage', '%#%' ),
		'format'       => '',
		'total'        => $max_page,
		'current'      => $page,
		'echo'         => true,
		'type'         => 'plain',
		'add_fragment' => '#comments',
	if ( $wp_rewrite->using_permalinks() ) {
		$defaults['base'] = user_trailingslashit( trailingslashit( get_permalink() ) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged' );

	$args       = wp_parse_args( $args, $defaults );
	$page_links = paginate_links( $args );

	if ( $args['echo'] && 'array' !== $args['type'] ) {
		echo $page_links;
	} else {
		return $page_links;



User Contributed Notes

  1. Skip to note 4 content

    Enhanced Comment Display

    WordPress makes comments.php files simple to write and edit. It’s simple to easily break comments into pages so that you don’t end up with hundreds of comments all loading on every pageview.

    You will need to set up the options in SETTINGS > DISCUSSION for paging to work.

    The easiest way to do so is with the following function, which prints out a link to the next and previous comment pages, as well as a numbered list of all the comment pages.

    paginate_comments_links( $args );

    It accepts an array or query-style list of arguments similar to get_posts() or get_terms() .

    If you want more control, you can also use the simpler next and previous functions:

    next_comments_link( $label = "", $max_page = 0 );


    previous_comments_link( $label = "" );
  2. Skip to note 5 content

    Custom Prev-/Next-links

    To modify the Prev- and Next-links, you can use the options ‘prev_text’ and ‘next_text’. These are provided by the function paginate_links() .

    paginate_comments_links( array(
    	'prev_text'  => 'back',
    	'next_text' => 'forward'
    ) );

    Note: If you want to use HTML entities in your ‘prev_text’ or ‘next_text’, you will have to use the array-based syntax.

    paginate_comments_links( array(
    	'prev_text' => '«',
    	'next_text' => '»'
    ) )

You must log in before being able to contribute a note or feedback.