Does XStore support menu item descriptions?

This topic has 4 replies, 2 voices, and was last updated 1 years ago ago by pablostevens

  • Avatar: pablostevens
    pablostevens
    Participant
    November 12, 2023 at 21:59

    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.

    3 Answers
    Avatar: Tony Rodriguez
    Tony Rodriguez
    Support staff
    November 13, 2023 at 08:43

    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.

    Avatar: pablostevens
    pablostevens
    Participant
    November 13, 2023 at 15:30

    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.

    Avatar: pablostevens
    pablostevens
    Participant
    November 13, 2023 at 16:28

    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;
    
    }
  • Viewing 4 results - 1 through 4 (of 4 total)

The issue related to '‘Does XStore support menu item descriptions?’' has been successfully resolved, and the topic is now closed for further responses

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.