WordPress函数:get_previous_comments_link 获取上一个评论的链接

江河/ 2023年06月07日/ WordPress/ 浏览 769

函数原型:


get_previous_comments_link( string $label = '' ): string|void


获取上一个评论的链接。


参数说明:


$label,注释链接文本的标签。默认值:“”


函数源码:


function get_previous_comments_link( $label = '' ) {
	if ( ! is_singular() ) {
		return;
	}

	$page = get_query_var( 'cpage' );

	if ( (int) $page <= 1 ) {
		return;
	}

	$previous_page = (int) $page - 1;

	if ( empty( $label ) ) {
		$label = __( '&laquo; Older Comments' );
	}

	$attr = apply_filters( 'previous_comments_link_attributes', '' );

	return sprintf(
		'<a href="%1$s" %2$s>%3$s</a>',
		esc_url( get_comments_pagenum_link( $previous_page ) ),
		$attr,
		preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label )
	);
}


包含钩子:


apply_filters( 'previous_comments_link_attributes', string $attributes )


发表评论

暂无评论,抢个沙发...

客服 工单