block_core_navigation_from_block_get_post_ids()WP 1.0

Get post IDs from a navigation link block instance.

Хуков нет.

Возвращает

Массив. Array of post IDs.

Использование

block_core_navigation_from_block_get_post_ids( $block );
$block(WP_Block) (обязательный)
Instance of a block.

Код block_core_navigation_from_block_get_post_ids() WP 6.0.2

function block_core_navigation_from_block_get_post_ids( $block ) {
	$post_ids = array();

	if ( $block->inner_blocks ) {
		$post_ids = block_core_navigation_get_post_ids( $block->inner_blocks );
	}

	if ( 'core/navigation-link' === $block->name || 'core/navigation-submenu' === $block->name ) {
		if ( $block->attributes && isset( $block->attributes['kind'] ) && 'post-type' === $block->attributes['kind'] ) {
			$post_ids[] = $block->attributes['id'];
		}
	}

	return $post_ids;
}