Home › Forums › Support › Moving secondary navigation menu to the sidebar but keep where is for mobile
- This topic has 7 replies, 3 voices, and was last updated 4 years, 3 months ago by
David.
-
AuthorPosts
-
February 11, 2022 at 3:18 am #2114046
William
Hi there,
I want to move the secondary navigation to a sidebar for desktop, but keep it where it is for mobile (at the top). Is there a way to do this? Is there also the ability to have elements just for mobile and desktop?
Kind regards,
Will
February 11, 2022 at 9:49 am #2114673Leo
StaffCustomer SupportHi Will,
Unfortunately I’m not aware of a solution for this.
One workaround I can think of is to use a navigation widget in the sidebar, and we can use CSS to hide it on mobile.
Let me know if this works for you 🙂
February 11, 2022 at 1:00 pm #2114927William
That could work, but I would still would like the menu to appear on mobile too, though.
For example, in the sidebar like this:

And then for mobile, to appear as standard like this:
February 11, 2022 at 6:57 pm #2115153Leo
StaffCustomer SupportI guess we could hide the secondary navigation on desktop and the menu widget on mobile?
February 12, 2022 at 5:07 am #2115482William
Possibly. How would that work? I currently have the secondary navigation set for left sidebar.
Is there any scope to have menus appear differently for desktop and mobile? A rule that looks at the width of screen and changes the location of the menu accordingly?
February 12, 2022 at 9:01 am #2115810David
StaffCustomer SupportHi there,
moving the Secondary Navigation out of the sidebar and to another container would require Javascript, and personally i don’t like that method as theres a risk that JS blockers on a browser may just break something.
Instead you would need to hook in a replica of the Secondary Navigation using a hook element with this HTML/PHP:
<div class="second-nav grid-container hide-on-desktop hide-on-tablet"> <?php if ( function_exists( 'generate_secondary_navigation_position' ) ) { generate_secondary_navigation_position(); } ?> </div>Try the
generate_after_headerhookI included the
hide-on-desktop hide-on-tabletclasses in the above HTML. Then you jut need some CSS to hide the sidebar one on Mobile:@media(max-width: 768px) { .gen-sidebar-secondary-nav { display: none; } }February 16, 2022 at 12:09 pm #2121748William
Amazing thank you!
February 17, 2022 at 3:04 am #2122401David
StaffCustomer SupportAwesome – glad to be of help!
-
AuthorPosts
- You must be logged in to reply to this topic.