wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



get_previous_comments_link › WordPress Function

Seit2.7.1
Veraltetn/v
get_previous_comments_link ( $label = '', $page = null )
Parameter: (2)
  • (string) $label Optional. Label for comments link text. Default empty.
    Erforderlich: Nein
    Standard: (leer)
  • (int|null) $page Optional. Page number. Default null.
    Erforderlich: Nein
    Standard: null
Gibt zurück:
  • (string|void) HTML-formatted link for the previous page of comments.
Definiert in:
Codex:
Changelog:
  • 6.7.0

Retrieves the link to the previous comments page.



Quellcode

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

	if ( is_null( $page ) ) {
		$page = get_query_var( 'cpage' );
	}

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

	$previous_page = (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.
	 */
	$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 )
	);
}