get_previous_comments_link example


}

/** * Displays the link to the previous comments page. * * @since 2.7.0 * * @param string $label Optional. Label for comments link text. Default empty. */
function previous_comments_link( $label = '' ) {
    echo get_previous_comments_link( $label );
}

/** * Displays or retrieves pagination links for the comments on the current post. * * @see paginate_links() * @since 2.7.0 * * @global WP_Rewrite $wp_rewrite WordPress rewrite component. * * @param string|array $args Optional args. See paginate_links(). Default empty array. * @return void|string|array Void if 'echo' argument is true and 'type' is not an array, * or if the query is not for an existing single post of any post type. * Otherwise, markup for comment page links or array of comment page links, * depending on 'type' argument. */
$label            = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? $attributes['label'] : $default_label;
    $pagination_arrow = get_comments_pagination_arrow( $block, 'previous' );
    if ( $pagination_arrow ) {
        $label = $pagination_arrow . $label;
    }

    $filter_link_attributes = static function() {
        return get_block_wrapper_attributes();
    };
    add_filter( 'previous_comments_link_attributes', $filter_link_attributes );

    $previous_comments_link = get_previous_comments_link( $label );

    remove_filter( 'previous_comments_link_attributes', $filter_link_attributes );

    if ( ! isset( $previous_comments_link ) ) {
        return '';
    }

    return $previous_comments_link;
}

/** * Registers the `core/comments-pagination-previous` block on the server. */
Home | Imprint | This part of the site doesn't use cookies.