paginate_comments_links

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

Description

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

Returns (string|void)

Markup for pagination links.

Parameters (1)

0. $args — Optional. (array) => array()
Args. See paginate_links(). Default empty array.

Usage

  1. if ( !function_exists( 'paginate_comments_links' ) ) { 
  2. require_once ABSPATH . WPINC . '/link-template.php'; 
  3.  
  4. // Optional args. See paginate_links(). Default empty array. 
  5. $args = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = paginate_comments_links($args); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/link-template.php  
  1. function paginate_comments_links( $args = array() ) { 
  2. global $wp_rewrite; 
  3.  
  4. if ( ! is_singular() ) 
  5. return; 
  6.  
  7. $page = get_query_var('cpage'); 
  8. if ( !$page ) 
  9. $page = 1; 
  10. $max_page = get_comment_pages_count(); 
  11. $defaults = array( 
  12. 'base' => add_query_arg( 'cpage', '%#%' ),  
  13. 'format' => '',  
  14. 'total' => $max_page,  
  15. 'current' => $page,  
  16. 'echo' => true,  
  17. 'add_fragment' => '#comments' 
  18. ); 
  19. if ( $wp_rewrite->using_permalinks() ) 
  20. $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged'); 
  21.  
  22. $args = wp_parse_args( $args, $defaults ); 
  23. $page_links = paginate_links( $args ); 
  24.  
  25. if ( $args['echo'] ) 
  26. echo $page_links; 
  27. else 
  28. return $page_links;