block_core_navigation_listable_blocks
Filter HookDescription
Filter the list of blocks that need a list item wrapper. Affords the ability to customize which blocks need a list item wrapper when rendered within a core/navigation block. This is useful for blocks that are not list items but should be wrapped in a list item when used as a child of a navigation block.Hook Information
| File Location |
wp-includes/blocks/navigation.php
View on GitHub
|
| Hook Type | Filter |
| Line Number | 138 |
Hook Parameters
| Type | Name | Description |
|---|---|---|
array
|
$needs_list_item_wrapper
|
The list of blocks that need a list item wrapper. |
Usage Examples
Basic Usage
<?php
// Hook into block_core_navigation_listable_blocks
add_filter('block_core_navigation_listable_blocks', 'my_custom_filter', 10, 1);
function my_custom_filter($needs_list_item_wrapper) {
// Your custom filtering logic here
return $needs_list_item_wrapper;
}
Source Code Context
wp-includes/blocks/navigation.php:138
- How this hook is used in WordPress core
<?php
133 * @since 6.5.0
134 *
135 * @param array $needs_list_item_wrapper The list of blocks that need a list item wrapper.
136 * @return array The list of blocks that need a list item wrapper.
137 */
138 $needs_list_item_wrapper = apply_filters( 'block_core_navigation_listable_blocks', static::$needs_list_item_wrapper );
139
140 return in_array( $block->name, $needs_list_item_wrapper, true );
141 }
142
143 /**
PHP Documentation
<?php
/**
* Filter the list of blocks that need a list item wrapper.
*
* Affords the ability to customize which blocks need a list item wrapper when rendered
* within a core/navigation block.
* This is useful for blocks that are not list items but should be wrapped in a list
* item when used as a child of a navigation block.
*
* @since 6.5.0
*
* @param array $needs_list_item_wrapper The list of blocks that need a list item wrapper.
* @return array The list of blocks that need a list item wrapper.
*/
Quick Info
- Hook Type: Filter
- Parameters: 1
- File: wp-includes/blocks/navigation.php
Related Hooks
Related hooks will be displayed here in future updates.