get_query_pagination_arrow() WordPress Function

The get_query_pagination_arrow() Wordpress function is used to display an arrow next to the current page number in the query results. This is useful for indicating to the user that there are more pages available to view.

get_query_pagination_arrow( WP_Block $block, boolean $is_next ) #

Helper function that returns the proper pagination arrow HTML for QueryPaginationNext and QueryPaginationPrevious blocks based on the provided paginationArrow from QueryPagination context.


Description

It’s used in QueryPaginationNext and QueryPaginationPrevious blocks.


Top ↑

Parameters

$block

(WP_Block)(Required)Block instance.

$is_next

(boolean)(Required)Flag for handling next/previous blocks.


Top ↑

Return

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


Top ↑

Source

File: wp-includes/blocks.php

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

Top ↑

Changelog

Changelog
VersionDescription
5.9.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.