get_comments_pagenum_link
Retrieves the comments page number link.
Description
Returns (string)
The comments page number link URL.
Parameters (2)
- 0. $pagenum — Optional. (int) =>
1
- Page number. Default 1.
- 1. $max_page — Optional. (int)
- The maximum number of comment pages. Default 0.
Usage
if ( !function_exists( 'get_comments_pagenum_link' ) ) { require_once ABSPATH . WPINC . '/link-template.php'; } // Optional. Page number. Default 1. $pagenum = 1; // Optional. The maximum number of comment pages. Default 0. $max_page = -1; // NOTICE! Understand what this does before running. $result = get_comments_pagenum_link($pagenum, $max_page);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/link-template.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 );
- }