This topic has 4 replies, 2 voices, and was last updated 1 years, 1 months ago ago by pablostevens
Does XStore support menu item descriptions? If so how to turn them on?
I enabled them in WP, but don’t show on front end.
Hello, @pablostevens,
Thank you for contacting us and for using XStore.
Did you read the description of the menu item description? https://prnt.sc/zrM5zympipAn
But with the next extra code, you will be able to show item description for menu item
1/ PHP part (add it to your child-theme/functions.php)
add_filter('walker_nav_menu_start_el', function ($item_output, $item, $depth, $args) {
$description = '';
if ( $item->description != '' ) {
$description = '<span class="menu-item-descr">' . do_shortcode( $item->description ) . '</span>';
}
return str_replace('</a>', $description.'</a>', $item_output);
}, 10, 4);
2/ CSS styles
.menu-item .menu-item-descr {
position: absolute;
top: 100%;
left: 50%;
transform: translateX(-50%);
}
We trust that you will find this information useful. Should you have any further queries or require additional assistance, please do not hesitate to contact us.
Best Regards,
8Theme’s Team.
Thank you Tony. That works. Although the text inside the mega menu isn’t inside the container. I had to set minimum height for the sub menu container. If you have a better idea of keeping the desc span inside the menu container, I’d love not to have to set the height explicitly.
I slightly improved upon your suggestion. I added <br>
before the description, and display:contents that makes it inside the container.
/*********turn on menu subtext*********/
add_filter('walker_nav_menu_start_el', function ($item_output, $item, $depth, $args) {
$description = '';
if ( $item->description != '' ) {
$description = '<br /><br><span class="menu-item-descr">' . do_shortcode( $item->description ) . '</span>';
}
return str_replace('</a>', $description.'</a>', $item_output);
}, 10, 4);
/********menu item sub text*********/
.menu-item .menu-item-descr {
text-transform: none;
font-size: 11px;
line-height: 1.3;
display:contents;
}
The issue related to '‘Does XStore support menu item descriptions?’' has been successfully resolved, and the topic is now closed for further responses