Archived topic
Sticky secondary menu
27 replies · Started by Rick on November 26, 2015
I had to put that in there temporarily because the mobile menu was messing with the vertical center alignment property in the header. That wasn't the issue if you disable that CSS then the issue persists.
Sorry for the confusion.
Little confused what the issue is currently? You are trying to hide one of the menus?
I have 2 navigations:
Primary: Used for Restaurant Menus page
Secondary: Used for All Pages (this is my main navigation)
I'm using the Primary nav on the Restaurant Menu page because it allows me to stick it for the abnormally long page.
I only want the Primary nav to be on the Restaurant Menu page because it is only applicable to the Restaurant Menu page. It lists the various Menus (i.e. Lunch, Dinner, etc.) via anchors. If you were to see this navigation on the About page (1) it wouldn't make sense and (2) the links won't work because the anchors wouldn't be on the About page
So I disabled the Primary nav on all pages BUT the Restaurant Menu page. Works perfectly EXCEPT when in mobile view, the Primary nav still shows on all the other pages. Not only that, but it messes with the vertical alignment of my page headers.
For the time being, I disabled the Primary nav completely with the CSS you mentioned above. But if you remove that style, you can see what is going on.
*Edit: I think I fixed the "messing with vertical alignment" problem with the page headers. But the issue of the mobile nav appearing still exists.
So you want to show only the Primary Nav (Menu) on the Menu page on mobile? But then people wouldn't be able to navigate to other pages?
Not quite. I want to show the Primary Nav always (Desktop and Mobile) on the Restaurant Menu page. I want to show the Primary Nav never (neither Desktop nor Mobile) on all other pages.
Hmm can you try disabling the mobile header feature? https://docs.generatepress.com/article/mobile-header/
Wow... it was that simple.
That worked. Not really sure why but hey I can finally move on to the next problem. Thanks for your help Leo!
No problem! Not an easy one to see :)
Nice work on the site Alex
Hey Tom,
Did you ever include the feature to have two menus sticky?
Thanks :)
Hi there,
there is not an built function for sticking both navs. We can help with some CSS, if you need to please raise a new topic :)
Hi
That is what this thread is supposed to be about. The original posted said "I just want to have 2 menus sticky."
There are a couple of options, we can for-go the GP Sticky navigation, and use the sticky CSS property on both navs.
Or we could use a snippet like so, which removes a before header secondary navigation and hooks it inside the primary nav, which will make both sticky:
add_action( 'after_setup_theme', 'lh_move_secondary_nav' );
function lh_move_secondary_nav() {
remove_action( 'generate_before_header', 'generate_add_secondary_navigation_before_header', 7 );
add_action( 'generate_inside_navigation', 'generate_add_secondary_navigation_before_header', 7 );
}
In both instances this would require site specific CSS to format and style. But nothing too complicated.