block_core_navigation_from_block_get_post_ids()
Get post IDs from a navigation link block instance.
No Hooks.
Returns
Array. Array of post IDs.
Usage
block_core_navigation_from_block_get_post_ids( $block );
- $block(WP_Block) (required)
- Instance of a block.
Changelog
| Since 6.0.0 | Introduced. |
block_core_navigation_from_block_get_post_ids() block core navigation from block get post ids code WP 6.9.1
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;
}