Snippet: 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 );
All PHP snippets should be added via child theme's functions.php file or via a plugin.
We recommend Code Snippets (100% Free) or WPCode (sponsored)
We recommend Code Snippets (100% Free) or WPCode (sponsored)