-
curiouslt
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!
-
curiouslt
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 🙂
-
curiouslt
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 🙂
-
curiouslt
i did not see that it wasn’t active, long week. Thank you so much for your help!
-
You are welcome 🙂
- You must be logged in to reply to this topic.