Site logo

[Support request] Add secondary menu to off canvas menu

Home Forums Support [Support request] Add secondary menu to off canvas menu

Home Forums Support Add secondary menu to off canvas menu

Viewing 15 posts - 1 through 15 (of 29 total)
  • Author
    Posts
  • #2539649
    Charles

    Hi there,

    On mobile I’m trying to remove the secondary menu from sitting under the main header. Is it possible to add the secondary menu to the off canvas menu?

    Any help would be greatly appreciated.

    Charles

    #2540088
    David
    Staff
    Customer Support

    Hi there,

    not easily, is the off canvas only on mobile ?

    #2540337
    Charles

    Hi David,

    Yes, the off canvas menu is only on mobile.

    As an alternative method is there a way to remove the secondary menu on mobile and add a button to the off canvas menu?

    Charles

    #2540342
    Ying
    Staff
    Customer Support

    Hi Charles,

    Try this PHP snippet to remove the secondary nav on mobile:

    add_filter( 'has_nav_menu', 'tu_disable_secondary_nav_on_mobile', 10, 2 );
    function tu_disable_secondary_nav_on_mobile( $has_nav_menu, $location ) {
        if ( 'secondary' === $location && wp_is_mobile() ) {
            return false;
        }
    
        return $has_nav_menu;
    }

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    add a button to the off canvas menu?

    What’s the purpose of the button?How it should be working?

    #2540391
    Charles

    Hi there,

    I’ve added the above code via the Code Snippets plugin but I can’t see that it’s worked.

    I want to add a ‘Get In Touch’ link on the off canvas menu.

    Charles

    #2540397
    Ying
    Staff
    Customer Support

    I’ve added the above code via the Code Snippets plugin but I can’t see that it’s worked.

    Have you checked on your phone? wp_is_mobile() works on the initial load, it will not work just by narrow down the browser window.

    And make sure the cache is cleared.

    I want to add a ‘Get In Touch’ link on the off canvas menu.

    You can use a block element – hook to insert this link, choose inside_slideout_navigation hook.

    #2540408
    Charles

    Hi,

    Is it quite difficult to add the secondary nav in to the off canvas menu before the primary nav? This would be the best solution if it was possible?

    Charles

    #2540559
    Ying
    Staff
    Customer Support

    Is it quite difficult to add the secondary nav in to the off canvas menu before the primary nav?

    The easiest way is to create a new menu with both secondary nav and primary nav’s menu items, then assign it to the off canvas menu.

    #2540963
    Charles

    Brilliant, I’ll do that.

    Thank you

    #2540977
    Charles

    Is the best way to turn off the secondary nav on mobile to use the PHP above?

    Charles

    #2541067
    David
    Staff
    Customer Support

    You can use the PHP function that Ying provided.
    But in addition you can add some CSS:

    @media(max-width: 768px) {
        #secondary-navigation {
            display: none;
        }
    }

    This will make sure the element is at least hidden if the wp_is_mobile doesn’t work

    #2541072
    Charles

    Great, thanks David.

    How is it possible to increase the logo size on mobile? I’m using navigation as a header but don’t want to increase the menu item height.

    Charles

    #2541105
    David
    Staff
    Customer Support

    Try this CSS:

    @media(max-width: 1024px) {
        #mobile-header .site-logo.mobile-header-logo img {
            padding: 0;
            height: 25px;
        }
    }
    #2541119
    Charles

    Great, that worked.

    Removing the secondary menu has left a white space where it was sitting. Is there a way to remove this?

    Charles

    #2541190
    David
    Staff
    Customer Support

    Can i see the site ?

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