get_next_comments_link()
最后更新于:2021-11-26 10:03:31
get_next_comments_link( string$label=”, int$max_page)Retrieves the link to the next comments page.
参数
- $label
-
(string) (Optional) Label for link text.
Default value: ”
- $max_page
-
(int) (Optional) Max page. Default 0.
响应
(string|void) HTML-formatted link for the next page of comments.
源文件
文件: gc-includes/link-template.php
function get_next_comments_link( $label = '', $max_page = 0 ) {
global $gc_query;
if ( ! is_singular() ) {
return;
}
$page = get_query_var( 'cpage' );
if ( ! $page ) {
$page = 1;
}
$nextpage = (int) $page + 1;
if ( empty( $max_page ) ) {
$max_page = $gc_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 »' );
}
/**
* 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', '&$1', $label ) . '</a>';
}