get_comments_pagenum_link()
最后更新于:2021-11-26 08:07:20
get_comments_pagenum_link( int$pagenum=1, int$max_page)Retrieves the comments page number link.
参数
- $pagenum
-
(int) (Optional) Page number.
Default value: 1
- $max_page
-
(int) (Optional) The maximum number of comment pages. Default 0.
响应
(string) The comments page number link URL.
源文件
文件: gc-includes/link-template.php
function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) {
global $gc_rewrite;
$pagenum = (int) $pagenum;
$result = get_permalink();
if ( 'newest' === get_option( 'default_comments_page' ) ) {
if ( $pagenum != $max_page ) {
if ( $gc_rewrite->using_permalinks() ) {
$result = user_trailingslashit( trailingslashit( $result ) . $gc_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged' );
} else {
$result = add_query_arg( 'cpage', $pagenum, $result );
}
}
} elseif ( $pagenum > 1 ) {
if ( $gc_rewrite->using_permalinks() ) {
$result = user_trailingslashit( trailingslashit( $result ) . $gc_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 );
}