Created
May 9, 2022 00:50
-
-
Save BruceMcKinnon/1f1acf093e591d082e0faa232a5418a9 to your computer and use it in GitHub Desktop.
Add menu item description to a menu item
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Add the menu item description to the visible title. | |
| // | |
| add_filter( 'nav_menu_item_title', 'nav_add_desc', 10, 4); | |
| function nav_add_desc( $title, $menu_item, $args, $depth ) { | |
| $retHtml = ''; | |
| $desc = $menu_item->description; | |
| if ( strlen($desc) > 0) { | |
| $desc = '<span>'.$desc.'</span>'; | |
| } | |
| return $title.$desc; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment