get_query_pagination_arrow

函式
get_query_pagination_arrow ( $block, $is_next )
引數
  • (WP_Block) $block Block instance.
    Required:
  • (bool) $is_next Flag for handling `next/previous` blocks.
    Required:
返回值
  • (string|null) The pagination arrow HTML or null if there is none.
定義位置
相關方法
get_comments_pagination_arrowget_the_posts_paginationget_user_optionget_query_varregister_block_core_query_pagination_previous
引入
5.9.0
棄用
-

get_query_pagination_arrow函式是一個WordPress函式,用於檢索查詢中下一頁或上一頁的分頁連結: 這個函式接受一個可選的連結文字引數,並返回到下一頁或上一頁的連結。

幫助函式,根據`QueryPagination`上下文提供的`paginationArrow`,為`QueryPaginationNext`和`QueryPaginationPrevious`區塊返回適當的分頁箭頭HTML。

它被用於QueryPaginationNext和QueryPaginationPrevious區塊。

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' aria-hidden='true'>$arrow</span>";
	}
	return null;
}

常見問題

FAQs
檢視更多 >