- This topic has 13 replies, 3 voices, and was last updated 4 years ago by David.
-
AuthorPosts
-
April 15, 2020 at 8:05 am #1240239Ruth Kijner
Hello,
I configured navigation as a header, and the header navigation is sticky.
Now I want to hide the navigation header when scrolling down in posts/articles on mobile.My first question is: Is it possible to hide the navigation header during scrolling down in all posts instead of doing this one by one?
My second question is: How to hide the navigation header during scrolling down on mobile?
I followed the instructions in topic https://generatepress.com/forums/topic/sticky-primary-navigation-for-specific-pages/
1. I tried to disable the sticky navigation in a specific article: https://www.perfectinvest.net/why-financial-literacy-is-important/
with the following CSS: .page-id-59 #sticky-navigation {display: none;} but it didn’t work.
(That CSS works great for home and about pages but not in education, top lists, and posts pages)2. I installed the Simple CSS plugin and added #sticky-navigation {display: none;} inside post, and it works great on desktop version but it doesn’t affect the mobile navigation header.
3. Just as mentioned in the article: https://docs.generatepress.com/article/sticky-navigation/#hide-when-scrolling-down
I disabled sticky navigation it didn’t affect only the mobile version.
I need your help.Thank you in advance
April 15, 2020 at 5:31 pm #1240834TomLead DeveloperLead DeveloperHi there,
What if you do this?:
.page-id-59 .navigation-stick, .page-id-59 #sticky-placeholder { display: none !important; }
Let me know ๐
April 15, 2020 at 11:26 pm #1241015Ruth KijnerHello Tom,
Thank you for your reply.I added the CSS you suggested, it took effect on desktop but not on mobile.
I can control the behavior of the navigation only from Customize –> Layout –> Header.
If I choose: Hide when scrolling down, or disabling sticky navigation. It’s actually the works great.I can’t find a way to disable sticky navigation or hide it when scrolling on specific pages
Maybe you have other suggestions?
Thank you so much in advance.
April 16, 2020 at 9:15 am #1241823TomLead DeveloperLead DeveloperWhich page can I check out? That CSS should work on mobile as well.
April 17, 2020 at 9:37 pm #1243748Ruth KijnerHello Tom,
It should work on posts pages like https://www.perfectinvest.net/why-financial-literacy-is-important/
Page ID:59Thank you!
April 18, 2020 at 9:46 am #1244489TomLead DeveloperLead DeveloperLet’s try removing the sticky script completely, instead of using CSS:
add_action( 'wp_enqueue_scripts', function() { if ( is_page( 59 ) ) { wp_dequeue_style( 'generate-sticky' ); wp_dequeue_script( 'generate-sticky' ); } }, 150 );
April 19, 2020 at 1:44 am #1245004Ruth KijnerHello Tom,
I deleted all CSS related to the sticky navigation. and added the PHP script to the snippet plugin, but it’s still not affecting the mobile.April 19, 2020 at 9:25 am #1245570TomLead DeveloperLead DeveloperCan you deactivate your caching/minifying plugin so I can take a closer look at the source?
April 19, 2020 at 12:41 pm #1245773Ruth KijnerHello Tom, I deactivated the caching/minifying plugin.
April 19, 2020 at 5:17 pm #1245968TomLead DeveloperLead DeveloperAh, it’s a post.
Try this:
add_action( 'wp_enqueue_scripts', function() { if ( is_single( 59 ) ) { wp_dequeue_style( 'generate-sticky' ); wp_dequeue_script( 'generate-sticky' ); } }, 150 );
April 19, 2020 at 11:00 pm #1246108Ruth KijnerHello Tom,
It’s working great, how can I apply this also on other posts?
Thank you
April 20, 2020 at 2:49 am #1246290DavidStaffCustomer SupportHi there,
Do you want to apply this to all posts ? If so this
if ( is_single( 59 ) ) {
becomes:
if (is_singular('post')) {
Or if you want to specify a list of posts by ID then this:
if ( is_single(array(59, 69, 79)) ) {
April 20, 2020 at 4:54 am #1246435Ruth KijnerIt’s working great, it’s so exciting! Thank you so much for all the help!
April 20, 2020 at 6:43 am #1246526DavidStaffCustomer SupportThats wonderful to hear ๐ Glad we could be of help
-
AuthorPosts
- You must be logged in to reply to this topic.