Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Combine Primary Menu and Off Canvas Menu on Mobile

  • Is there a way to combine thePrimary Menu and Off Canvas Menu on mobile? I’m using the primary navigation bar and off canvas panel on desktop, but on mobile, only the off canvas appears. Is there a way to add the items from the primary menu to the off canvas on mobile only?

  • Hi there,

    You can create another menu at appearance > menus, give it a name like slideout-mobile.

    Then add this PHP code to force the slideout navigation to use the new menu on mobile:

    add_filter( 'wp_nav_menu_args', function ( $args ) {
    	if ( 'slideout' === $args['theme_location']  && wp_is_mobile() ){
    		
                $args['menu'] = 25;
        }
    
        return $args;
    } );

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

    Note: the 25 is the id of the menu, you can find it in the URL when editing that menu.

    Let me know if there’s anything unclear!

  • Add the php code via code snippets, but not working. Doesn’t show up.

  • Can I see how you added the code and also the new menu?

    Let me know 🙂

  • Do you mean admin access? If yes, I’m adding that in the private area below. If not, did you want screenshots?

  • I checked, and the code was inactive, I’ve activated it.

    To see the result, you need to check on real mobile devices.

    Let me know 🙂

  • i did not see that it wasn’t active, long week. Thank you so much for your help!

  • You are welcome   🙂

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