wp_nav_menu_objects
Filter HookDescription
Filters the sorted list of menu item objects before generating the menu's HTML.Hook Information
File Location |
wp-includes/nav-menu-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 239 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$sorted_menu_items
|
The menu items, sorted by each menu item's menu order. |
stdClass
|
$args
|
An object containing wp_nav_menu() arguments. |
Usage Examples
Basic Usage
<?php
// Hook into wp_nav_menu_objects
add_filter('wp_nav_menu_objects', 'my_custom_filter', 10, 2);
function my_custom_filter($sorted_menu_items, $args) {
// Your custom filtering logic here
return $sorted_menu_items;
}
Source Code Context
wp-includes/nav-menu-template.php:239
- How this hook is used in WordPress core
<?php
234 * @since 3.1.0
235 *
236 * @param array $sorted_menu_items The menu items, sorted by each menu item's menu order.
237 * @param stdClass $args An object containing wp_nav_menu() arguments.
238 */
239 $sorted_menu_items = apply_filters( 'wp_nav_menu_objects', $sorted_menu_items, $args );
240
241 $items .= walk_nav_menu_tree( $sorted_menu_items, $args->depth, $args );
242 unset( $sorted_menu_items );
243
244 // Attributes.
PHP Documentation
<?php
/**
* Filters the sorted list of menu item objects before generating the menu's HTML.
*
* @since 3.1.0
*
* @param array $sorted_menu_items The menu items, sorted by each menu item's menu order.
* @param stdClass $args An object containing wp_nav_menu() arguments.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/nav-menu-template.php
Related Hooks
Related hooks will be displayed here in future updates.