widget_nav_menu_args
Filter HookDescription
Filters the arguments for the Navigation Menu widget. }Hook Information
File Location |
wp-includes/widgets/class-wp-nav-menu-widget.php
View on GitHub
|
Hook Type | Filter |
Line Number | 109 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$nav_menu_args
|
{ An array of arguments passed to wp_nav_menu() to retrieve a navigation menu. |
WP_Term
|
$nav_menu
|
Nav menu object for the current menu. |
array
|
$args
|
Display arguments for the current widget. |
array
|
$instance
|
Array of settings for the current widget. |
Usage Examples
Basic Usage
<?php
// Hook into widget_nav_menu_args
add_filter('widget_nav_menu_args', 'my_custom_filter', 10, 4);
function my_custom_filter($nav_menu_args, $nav_menu, $args, $instance) {
// Your custom filtering logic here
return $nav_menu_args;
}
Source Code Context
wp-includes/widgets/class-wp-nav-menu-widget.php:109
- How this hook is used in WordPress core
<?php
104 * }
105 * @param WP_Term $nav_menu Nav menu object for the current menu.
106 * @param array $args Display arguments for the current widget.
107 * @param array $instance Array of settings for the current widget.
108 */
109 wp_nav_menu( apply_filters( 'widget_nav_menu_args', $nav_menu_args, $nav_menu, $args, $instance ) );
110
111 echo $args['after_widget'];
112 }
113
114 /**
PHP Documentation
<?php
/**
* Filters the arguments for the Navigation Menu widget.
*
* @since 4.2.0
* @since 4.4.0 Added the `$instance` parameter.
*
* @param array $nav_menu_args {
* An array of arguments passed to wp_nav_menu() to retrieve a navigation menu.
*
* @type callable|bool $fallback_cb Callback to fire if the menu doesn't exist. Default empty.
* @type mixed $menu Menu ID, slug, or name.
* }
* @param WP_Term $nav_menu Nav menu object for the current menu.
* @param array $args Display arguments for the current widget.
* @param array $instance Array of settings for the current widget.
*/
Quick Info
- Hook Type: Filter
- Parameters: 4
- File: wp-includes/widgets/class-wp-nav-menu-widget.php
Related Hooks
Related hooks will be displayed here in future updates.