pre_wp_nav_menu
Filters whether to short-circuit the wp_nav_menu() output.
Returning a non-null value from the filter will short-circuit wp_nav_menu(), echoing that value if $args->echo is true, returning that value otherwise.
Usage
add_filter( 'pre_wp_nav_menu', 'wp_kama_pre_wp_nav_menu_filter', 10, 2 ); /** * Function for `pre_wp_nav_menu` filter-hook. * * @param string|null $output Nav menu output to short-circuit with. * @param stdClass $args An object containing wp_nav_menu() arguments. * * @return string|null */ function wp_kama_pre_wp_nav_menu_filter( $output, $args ){ // filter... return $output; }
- $output(string|null)
- Nav menu output to short-circuit with.
Default: null - $args(stdClass)
- An object containing wp_nav_menu() arguments.
Changelog
Since 3.9.0 | Introduced. |
Where the hook is called
pre_wp_nav_menu
wp-includes/nav-menu-template.php 113
$nav_menu = apply_filters( 'pre_wp_nav_menu', null, $args );