WordPress at a glance

get_next_comments_link() WP 1.0

Retrieves the link to the next comments page.

  • Global. WP_Query. $wp_query
✈ 1 time = 0.00019s = fast | 50000 times = 2.7s = fast
Hooks from function:
Return

String/null. HTML-formatted link for the next page of comments.

Usage

get_next_comments_link( $label, $max_page );
$label(string)
Label for link text.
Default: ''
$max_page(int)
Max page.
Default: 0

Code of get_next_comments_link: wp-includes/link-template.php VER 4.9.8

<?php
function get_next_comments_link( $label = '', $max_page = 0 ) {
	global $wp_query;

	if ( ! is_singular() )
		return;

	$page = get_query_var('cpage');

	if ( ! $page ) {
		$page = 1;
	}

	$nextpage = intval($page) + 1;

	if ( empty($max_page) )
		$max_page = $wp_query->max_num_comment_pages;

	if ( empty($max_page) )
		$max_page = get_comment_pages_count();

	if ( $nextpage > $max_page )
		return;

	if ( empty($label) )
		$label = __('Newer Comments &raquo;');

	/**
	 * Filters the anchor tag attributes for the next comments page link.
	 *
	 * @since 2.7.0
	 *
	 * @param string $attributes Attributes for the anchor tag.
	 */
	return '<a href="' . esc_url( get_comments_pagenum_link( $nextpage, $max_page ) ) . '" ' . apply_filters( 'next_comments_link_attributes', '' ) . '>'. preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label) .'</a>';
}

Related Functions

From tag: Comments pagination (navigation)

More from tag: Comments

More from tag: Link (URL)

More from category: Comments

No comments
    Hello, !     Log In . Register