Site logo

[Support request] Moving secondary navigation menu to the sidebar but keep where is for mobile

Home Forums Support [Support request] Moving secondary navigation menu to the sidebar but keep where is for mobile

Home Forums Support Moving secondary navigation menu to the sidebar but keep where is for mobile

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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

    #2114673
    Leo
    Staff
    Customer Support

    Hi 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 🙂

    #2114927
    William

    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:

    #2115153
    Leo
    Staff
    Customer Support

    I guess we could hide the secondary navigation on desktop and the menu widget on mobile?

    #2115482
    William

    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?

    #2115810
    David
    Staff
    Customer Support

    Hi 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_header hook

    I included the hide-on-desktop hide-on-tablet classes 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;
        }
    }
    #2121748
    William

    Amazing thank you!

    #2122401
    David
    Staff
    Customer Support

    Awesome – glad to be of help!

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