paginate_comments_links

Definition:
function paginate_comments_links($args = array() {}

Create pagination links for the comments on the current post.

Parameters

  • string|array $args: Optional args. See paginate_links().

Return values

returns:Markup for pagination links.

Source code

function paginate_comments_links($args = array()) {

	global $wp_rewrite;



	if ( !is_singular() || !get_option('page_comments') )

		return;



	$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,

		'add_fragment' => '#comments'

	);

	if ( $wp_rewrite->using_permalinks() )

		$defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . 'comment-page-%#%', 'commentpaged');



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

	$page_links = paginate_links( $args );



	if ( $args['echo'] )

		echo $page_links;

	else

		return $page_links;

}

2475

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: