A WordPress-centric search engine for devs and theme authors



get_previous_comments_link ›

Since2.7.1
Deprecatedn/a
get_previous_comments_link ( $label = '' )
Parameters:
  • (string) $label Optional. Label for comments link text. Default empty.
    Required: No
    Default: (empty)
Returns:
  • (string|void) HTML-formatted link for the previous page of comments.
Defined at:
Codex:

Retrieves the link to the previous comments page.



Source

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

	$page = get_query_var( 'cpage' );

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

	$prevpage = intval( $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', '&#038;$1', $label ) . '</a>';
}