WordPress lets you add descriptions on menu items by clicking “Screen Options” when editing the menu (top right corner) and checking “Description”. But most themes don’t support these out of the box, so you’ll need to add support yourself.

  • Custom WP

Most approaches I’ve seen call for using walkers, which are complicated and could conflict with your theme if you’re already using a custom walker. This solution is much simpler.

In the code below I’m using the ‘walker_nav_menu_start_el’ filter to modify the menu item. I’m checking to see if the menu is in the ‘header’ theme location (I only wanted this on one specific menu), that $depth = 0 (it’s a top level menu item), and that the menu item has a description. If all of those are true, I add the description to the end of the menu item



/**
* Descriptions on Header Menu
*
*/

function customwp_header_menu_desc( $item_output, $item, $depth, $args ) {if( 'header' == $args->theme_location && ! $depth && $item->description )

$item_output = str_replace( '', '' . $item->description . '', $item_output );

return $item_output;
}
add_filter( 'walker_nav_menu_start_el', 'customwp_header_menu_desc', 10, 4 );



Code Snippets Custom Function Custom WordPress Menu WordPress
WordPress