get_comments_pagination_arrow() WordPress Function

The get_comments_pagination_arrow() function is used to display a link to the next or previous set of comments, when viewing a post with multiple pages of comments. This function is used internally by the Wordpress comments system, and is not intended to be called directly by themes or plugins.

get_comments_pagination_arrow( WP_Block $block, string $pagination_type = 'next' ) #

Helper function that returns the proper pagination arrow HTML for CommentsPaginationNext and CommentsPaginationPrevious blocks based on the provided paginationArrow from CommentsPagination context.


Description

It’s used in CommentsPaginationNext and CommentsPaginationPrevious blocks.


Top ↑

Parameters

$block

(WP_Block)(Required)Block instance.

$pagination_type

(string)(Optional)Type of the arrow we will be rendering. Accepts 'next' or 'previous'.

Default value: 'next'


Top ↑

Return

(string|null) The pagination arrow HTML or null if there is none.


Top ↑

Source

File: wp-includes/blocks.php

function get_comments_pagination_arrow( $block, $pagination_type = 'next' ) {
	$arrow_map = array(
		'none'    => '',
		'arrow'   => array(
			'next'     => '→',
			'previous' => '←',
		),
		'chevron' => array(
			'next'     => '»',
			'previous' => '«',
		),
	);
	if ( ! empty( $block->context['comments/paginationArrow'] ) && ! empty( $arrow_map[ $block->context['comments/paginationArrow'] ][ $pagination_type ] ) ) {
		$arrow_attribute = $block->context['comments/paginationArrow'];
		$arrow           = $arrow_map[ $block->context['comments/paginationArrow'] ][ $pagination_type ];
		$arrow_classes   = "wp-block-comments-pagination-$pagination_type-arrow is-arrow-$arrow_attribute";
		return "<span class='$arrow_classes'>$arrow</span>";
	}
	return null;
}

Top ↑

Changelog

Changelog
VersionDescription
6.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.