- This topic has 5 replies, 3 voices, and was last updated 5 years, 6 months ago by
Elvin.
-
AuthorPosts
-
October 22, 2020 at 10:25 am #1500279
Bill
Do you know how I can get the Menu Item Description to show in a sidebar? I see a thread on these forums about adding the code to the Primary/Secondary menus, which I added, but the sidebar descriptions don’t show. I must need code for the descriptions to show in the sidebar.
Any ideas how to get that showing? ~ Thanks Bill
October 22, 2020 at 11:46 am #1500362Leo
StaffCustomer SupportHi there,
Not quite sure if I fully understand.
Can you link me to the post you are referring to or an example of what you are trying to achieve?
Thanks 🙂
October 22, 2020 at 11:54 am #1500375Bill
https://generatepress.com/forums/topic/adding-description-under-menu/
I would like to use the Menu in the sidebar with the description showing.
Here’s what I’ve done:
1. Appearance >> Menus >> Screen Options >> Description is selected.
2. Menu items created with descriptions
3. Added menu to sidebar
4. Menu title shows
5. Menu description does not show
6. I would like to show the menu description under the menu title
October 22, 2020 at 8:41 pm #1500680Elvin
StaffCustomer SupportHi Bill,
You can try this PHP snippet:
function add_nav_description( $item_output, $item, $depth, $args ) { $menu_name = 'Your menu name here'; if ( !empty( $item->description) && $menu_name == $args->menu->name ) { $item_output = str_replace( $args->link_after . '</a>', '<div class="menu-item-description">' . $item->description . '</div>' . $args->link_after . '</a>', $item_output ); } return $item_output; } add_filter( 'walker_nav_menu_start_el', 'add_nav_description', 10, 4 );Here’s how to add PHP – https://docs.generatepress.com/article/adding-php/
Just change the
$menu_namevalue to the name of your menu w/ description.You then use this CSS for styling:
.menu-item-description { margin-left: 20px; color: black; font-size: 14px; }Here’s how to add CSS: – https://docs.generatepress.com/article/adding-css/
Let us know if you need further styling.
October 23, 2020 at 6:24 am #1501161Bill
That worked perfectly. Thanks for your help. I appreciate it. ~ Bill
October 25, 2020 at 12:22 pm #1503838Elvin
StaffCustomer SupportNice one.
No problem. 😀
-
AuthorPosts
- You must be logged in to reply to this topic.