get_previous_comments_link

函式
get_previous_comments_link ( $label = '' )
引數
  • (string) $label Optional. Label for comments link text. Default empty.
    Required:
    Default: (empty)
返回值
  • (string|void) HTML-formatted link for the previous page of comments.
定義位置
相關方法
previous_comments_linkget_previous_posts_linkget_previous_post_linkget_previous_image_linkget_edit_comment_link
引入
2.7.1
棄用
-

get_previous_comments_link函式是一個WordPress函式,用於檢索指向前一個評論頁面的連結的HTML標記: 這個函式接受一個可選的引數作為連結文字,並返回到上一個評論頁面的連結的HTML標記。

檢索到前一個評論頁面的連結。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_previous_comments_link( $label = '' ) {
if ( ! is_singular() ) {
return;
}
$page = get_query_var( 'cpage' );
if ( (int) $page <= 1 ) {
return;
}
$prevpage = (int) $page - 1;
if ( empty( $label ) ) {
$label = __( '&laquo; Older Comments' );
}
/**
* Filters the anchor tag attributes for the previous comments page link.
*
* @since 2.7.0
*
* @param string $attributes Attributes for the anchor tag.
*/
return '<a href="' . esc_url( get_comments_pagenum_link( $prevpage ) ) . '" ' . apply_filters( 'previous_comments_link_attributes', '' ) . '>' . preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) . '</a>';
}
function get_previous_comments_link( $label = '' ) { if ( ! is_singular() ) { return; } $page = get_query_var( 'cpage' ); if ( (int) $page <= 1 ) { return; } $prevpage = (int) $page - 1; if ( empty( $label ) ) { $label = __( '&laquo; Older Comments' ); } /** * Filters the anchor tag attributes for the previous comments page link. * * @since 2.7.0 * * @param string $attributes Attributes for the anchor tag. */ return '<a href="' . esc_url( get_comments_pagenum_link( $prevpage ) ) . '" ' . apply_filters( 'previous_comments_link_attributes', '' ) . '>' . preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) . '</a>'; }
function get_previous_comments_link( $label = '' ) {
	if ( ! is_singular() ) {
		return;
	}

	$page = get_query_var( 'cpage' );

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

	$prevpage = (int) $page - 1;

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

	/**
	 * Filters the anchor tag attributes for the previous comments page link.
	 *
	 * @since 2.7.0
	 *
	 * @param string $attributes Attributes for the anchor tag.
	 */
	return '<a href="' . esc_url( get_comments_pagenum_link( $prevpage ) ) . '" ' . apply_filters( 'previous_comments_link_attributes', '' ) . '>' . preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) . '</a>';
}

常見問題

FAQs
檢視更多 >