widget_nav_menu_args filter-hookWP 4.2.0

Filters the arguments for the Navigation Menu widget.

Usage

add_filter( 'widget_nav_menu_args', 'wp_kama_widget_nav_menu_args_filter', 10, 4 );

/**
 * Function for `widget_nav_menu_args` filter-hook.
 * 
 * @param array   $nav_menu_args An array of arguments passed to wp_nav_menu() to retrieve a navigation menu.
 * @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.
 *
 * @return array
 */
function wp_kama_widget_nav_menu_args_filter( $nav_menu_args, $nav_menu, $args, $instance ){

	// filter...
	return $nav_menu_args;
}
$nav_menu_args(array)

An array of arguments passed to wp_nav_menu() to retrieve a navigation menu.

  • fallback_cb(callable|true|false)
    Callback to fire if the menu doesn't exist.
    Default: ''

  • menu(mixed)
    Menu ID, slug, or name.
$nav_menu(WP_Term)
Nav menu object for the current menu.
$args(array)
Display arguments for the current widget.
$instance(array)
Array of settings for the current widget.

Changelog

Since 4.2.0 Introduced.
Since 4.4.0 Added the $instance parameter.

Where the hook is called

WP_Nav_Menu_Widget::widget()
widget_nav_menu_args
wp-includes/widgets/class-wp-nav-menu-widget.php 109
wp_nav_menu( apply_filters( 'widget_nav_menu_args', $nav_menu_args, $nav_menu, $args, $instance ) );

Where the hook is used in WordPress

Usage not found.