[Resolved] How to add custom menu item onto a menu in the Top Bar?

Home Forums Support [Resolved] How to add custom menu item onto a menu in the Top Bar?

Home Forums Support How to add custom menu item onto a menu in the Top Bar?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1587377
    William

    Referring to this: https://docs.generatepress.com/article/generate_menu_bar_items/

    How can I add a custom menu item onto a menu that I’ve put into the Top Bar?

    Thanks in advance for any and all help!

    #1587491
    Leo
    Staff
    Customer Support

    Hi there,

    Any chance you can link us to the site in question?

    You can use the private information field.

    Let me know 🙂

    #1587946
    William

    URL provided in private info, thanks.
    The goal is to keep this a menu.

    #1587995
    David
    Staff
    Customer Support

    Hi there,

    the generate_menu_bar_items only exists inside the Primary Nav and Mobile Header.

    For you top bar menu – is it the Email link you wish to add ? If so can simply add a Custom Link to your menu to include the Email label and add your mailto:”email-address” as the menu items URL.

    Let me know,

    #1588220
    William

    Shouldn’t this work – if I could somehow figure out the theme_location for a menu that I put in the Top Bar?

    add_filter( 'wp_nav_menu_items', function( $nav, $args ) {
        if ( $args->theme_location == 'topbar_nav_menu' ) {
            return $nav . '<span class="menu-bar-item">Email: <a href="#">person@domain.com</a></span>';
        }
        return $nav;
    }, 10, 2 );
    #1588233
    David
    Staff
    Customer Support

    Navigation widgets don’t have a theme_location as they are a widget
    Why not just use the method i suggested with adding it as a menu item ?

    #1588273
    William

    Okay, thanks I’ve done that.

    Using this CSS should help in case the client adds another menu item (just as long as it’s not the last menu item).

    .menu-top-bar-container .menu > li:last-child:before {
        content: "Email: ";
    }
    #1588276
    David
    Staff
    Customer Support

    You can add HTML to your Menu item label as well

    eg.

    <span class="email-label">Email: </span>youremail@wherever.com

    Glad you its working for you.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.