Skip to content

Instantly share code, notes, and snippets.

@eccentricpixel
Created January 17, 2014 19:45
Show Gist options
  • Save eccentricpixel/8480112 to your computer and use it in GitHub Desktop.
Save eccentricpixel/8480112 to your computer and use it in GitHub Desktop.
Adds a span tag of the TITLE attribute in the output of Wordpress menus
add_filter('walker_nav_menu_start_el', 'description_in_nav_el', 10, 4);
function description_in_nav_el($item_output, $item, $depth, $args)
{
return preg_replace('/(<a.*?>[^<]*?)</', "<span>{$item->attr_title}</span>" . '$1' . "<", $item_output);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment