Filter hook 'nav_menu_item_title'

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

View Source

nav_menu_item_title

Filter Hook
Description
Filters a menu item's title.

Hook Information

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

Hook Parameters

Type Name Description
string $title The menu item's title.
WP_Post $menu_item The current menu item object.
stdClass $args An object of wp_nav_menu() arguments.
int $depth Depth of menu item. Used for padding.

Usage Examples

Basic Usage
<?php
// Hook into nav_menu_item_title
add_filter('nav_menu_item_title', 'my_custom_filter', 10, 4);

function my_custom_filter($title, $menu_item, $args, $depth) {
    // Your custom filtering logic here
    return $title;
}

Source Code Context

wp-includes/class-walker-nav-menu.php:249 - How this hook is used in WordPress core
<?php
 244  		 * @param string   $title     The menu item's title.
 245  		 * @param WP_Post  $menu_item The current menu item object.
 246  		 * @param stdClass $args      An object of wp_nav_menu() arguments.
 247  		 * @param int      $depth     Depth of menu item. Used for padding.
 248  		 */
 249  		$title = apply_filters( 'nav_menu_item_title', $title, $menu_item, $args, $depth );
 250  
 251  		$atts           = array();
 252  		$atts['target'] = ! empty( $menu_item->target ) ? $menu_item->target : '';
 253  		$atts['rel']    = ! empty( $menu_item->xfn ) ? $menu_item->xfn : '';
 254  

PHP Documentation

<?php
/**
		 * Filters a menu item's title.
		 *
		 * @since 4.4.0
		 *
		 * @param string   $title     The menu item's title.
		 * @param WP_Post  $menu_item The current menu item object.
		 * @param stdClass $args      An object of wp_nav_menu() arguments.
		 * @param int      $depth     Depth of menu item. Used for padding.
		 */
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.