Filter hook 'walker_nav_menu_start_el'

in WP Core File wp-includes/class-walker-nav-menu.php at line 320

View Source

walker_nav_menu_start_el

Filter Hook
Description
Filters a menu item's starting output. The menu item's starting output only includes `$args->before`, the opening ``, the menu item's title, the closing ``, and `$args->after`. Currently, there is no filter for modifying the opening and closing `
  • ` for a menu item.
  • Hook Information

    File Location wp-includes/class-walker-nav-menu.php View on GitHub
    Hook Type Filter
    Line Number 320

    Hook Parameters

    Type Name Description
    string $item_output The menu item's starting HTML output.
    WP_Post $menu_item Menu item data object.
    int $depth Depth of menu item. Used for padding.
    stdClass $args An object of wp_nav_menu() arguments.

    Usage Examples

    Basic Usage
    <?php
    // Hook into walker_nav_menu_start_el
    add_filter('walker_nav_menu_start_el', 'my_custom_filter', 10, 4);
    
    function my_custom_filter($item_output, $menu_item, $depth, $args) {
        // Your custom filtering logic here
        return $item_output;
    }
    

    Source Code Context

    wp-includes/class-walker-nav-menu.php:320 - How this hook is used in WordPress core
    <?php
     315  		 * @param string   $item_output The menu item's starting HTML output.
     316  		 * @param WP_Post  $menu_item   Menu item data object.
     317  		 * @param int      $depth       Depth of menu item. Used for padding.
     318  		 * @param stdClass $args        An object of wp_nav_menu() arguments.
     319  		 */
     320  		$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $menu_item, $depth, $args );
     321  	}
     322  
     323  	/**
     324  	 * Ends the element output, if needed.
     325  	 *
    

    PHP Documentation

    <?php
    /**
    		 * 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.
    		 *
    		 * @since 3.0.0
    		 *
    		 * @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.
    		 */
    Quick Info
    • Hook Type: Filter
    • Parameters: 4
    • File: wp-includes/class-walker-nav-menu.php
    Related Hooks

    Related hooks will be displayed here in future updates.