walker_nav_menu_start_el filter-hookWP 3.0.0

Filters a menu item's starting output.

The menu item's starting output only includes $args->before, the opening <a>, the menu item's title, the closing </a>, and $args->after. Currently, there is no filter for modifying the opening and closing <li> for a menu item.

Usage

add_filter( 'walker_nav_menu_start_el', 'wp_kama_walker_nav_menu_start_el_filter', 10, 4 );

/**
 * Function for `walker_nav_menu_start_el` filter-hook.
 * 
 * @param string   $item_output The menu item's starting HTML output.
 * @param WP_Post  $menu_item   Menu item data object.
 * @param int      $depth       Depth of menu item. Used for padding.
 * @param stdClass $args        An object of wp_nav_menu() arguments.
 *
 * @return string
 */
function wp_kama_walker_nav_menu_start_el_filter( $item_output, $menu_item, $depth, $args ){

	// filter...
	return $item_output;
}
$item_output(string)
The menu item's starting HTML output.
$menu_item(WP_Post)
Menu item data object.
$depth(int)
Depth of menu item. Used for padding.
$args(stdClass)
An object of wp_nav_menu() arguments.

Changelog

Since 3.0.0 Introduced.

Where the hook is called

Walker_Nav_Menu::start_el()
walker_nav_menu_start_el
wp-includes/class-walker-nav-menu.php 252
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $menu_item, $depth, $args );

Where the hook is used in WordPress

Usage not found.