Snippets: Display Menu Descriptions in Main Menu

add_filter( 'walker_nav_menu_start_el', function( $item_output, $item, $depth, $args ) {
	if ( 'main_menu' == $args->theme_location && $item->description ) {
		$item_output = str_replace( '</a>', '<span class="my-menu-item-desc">' . $item->description . '</span></a>', $item_output );
	}
	return $item_output;
}, 10, 4 );

Snippet Type: PHP

Posted Under: Menu

All PHP snippets should be added via a child theme's functions.php file or via the Code Snippets Plugin (or alternative plugin)