WordPress at a glance

get_comments_pagenum_link() WP 1.0

Retrieves the comments page number link.

1 time — 0.00016 sec (fast) | 50000 times — 5.76 sec (fast)
Hooks from the function
Return

String. The comments page number link URL.

Usage

get_comments_pagenum_link( $pagenum, $max_page );
$pagenum(int)
Page number.
Default: 1
$max_page(int)
The maximum number of comment pages.

Notes

  • Global. WP_Rewrite. $wp_rewrite WordPress rewrite component.

Changelog

Since 2.7.0 Introduced.

Code of get_comments_pagenum_link() WP 5.7.2

<?php
function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) {
	global $wp_rewrite;

	$pagenum = (int) $pagenum;

	$result = get_permalink();

	if ( 'newest' === get_option( 'default_comments_page' ) ) {
		if ( $pagenum != $max_page ) {
			if ( $wp_rewrite->using_permalinks() ) {
				$result = user_trailingslashit( trailingslashit( $result ) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged' );
			} else {
				$result = add_query_arg( 'cpage', $pagenum, $result );
			}
		}
	} elseif ( $pagenum > 1 ) {
		if ( $wp_rewrite->using_permalinks() ) {
			$result = user_trailingslashit( trailingslashit( $result ) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged' );
		} else {
			$result = add_query_arg( 'cpage', $pagenum, $result );
		}
	}

	$result .= '#comments';

	/**
	 * Filters the comments page number link for the current request.
	 *
	 * @since 2.7.0
	 *
	 * @param string $result The comments page number link.
	 */
	return apply_filters( 'get_comments_pagenum_link', $result );
}

From tag: Comments pagination (navigation)

More from tag: Comments

More from tag: Link (URL)

More from category: Comments

No comments
    Log In