block_core_navigation_from_block_get_post_ids

函数
block_core_navigation_from_block_get_post_ids ( $block )

block_core_navigation_from_block_get_post_ids: 这个函数是用来获取导航块的文章ID。它从块的设置中检索文章的ID。

从一个导航链接块实例中获取文章ID。

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'] && isset( $block->attributes['id'] ) ) {
			$post_ids[] = $block->attributes['id'];
		}
	}

	return $post_ids;
}

常见问题

FAQs
查看更多 >