- This topic has 17 replies, 3 voices, and was last updated 6 years, 8 months ago by Tom.
-
AuthorPosts
-
July 21, 2017 at 2:30 am #352659ilovemusic
Hey!
I want to show sticky menu only on homepage!
Wondering if this is possible with either a Plugin or basic html or by adding the code in the header or footer webhooks.
I am not new to HTML and can manage.July 21, 2017 at 9:22 am #352816LeoStaffCustomer SupportHi there,
Try this CSS:
.main-navigation.navigation-stick { display: none; } .home .main-navigation.navigation-stick { display: block !important; }
Adding CSS: https://docs.generatepress.com/article/adding-css/
July 21, 2017 at 9:31 am #352824TomLead DeveloperLead DeveloperThat likely won’t work, as it will always display the sticky menu, even when not sticky.
Try this:
body:not(.home) #sticky-navigation, body:not(.home) #sticky-placeholder { display: none; }
July 22, 2017 at 3:08 am #353146ilovemusicHey Tom,
Used your given CSS above!
Thanks that works!
The sticky menu now has been deactivated on all pages except my home page.However, whenever I scroll up and down on a page, the primary too disappears.
Could you suggest?
Thanks.
July 22, 2017 at 11:41 am #353265TomLead DeveloperLead DeveloperCan you link me to the page?
July 25, 2017 at 1:13 am #354450ilovemusicHey Tom,
Here’s the link to the page! Please check 🙂
http://demo.ilovemusic.edu.in/emp2-2/Scrolling up and down makes the primary navigation disappear too!
Thanks!
July 25, 2017 at 8:37 am #354648LeoStaffCustomer SupportHmm can’t seem to get the primary menu to disappear after scrolling up and down a few times…
July 25, 2017 at 9:35 am #354678TomLead DeveloperLead DeveloperLet’s try this PHP instead:
add_action( 'wp_enqueue_scripts','tu_disable_home_sticky', 100 ); function tu_disable_home_sticky() { if ( is_front_page() ) { wp_dequeue_script( 'generate-sticky' ); } }
July 26, 2017 at 1:43 am #355102ilovemusicHello!
So i added the php that you provided above using the Spippets plugin for wordpress.
add_action( ‘wp_enqueue_scripts’,’tu_disable_home_sticky’, 100 );
function tu_disable_home_sticky() {
if ( is_front_page() ) {
wp_dequeue_script( ‘generate-sticky’ );
}
}This function however is only deactivating the sticky on all pages. :/
Any suggestions?
Thanks.July 26, 2017 at 9:49 am #355310TomLead DeveloperLead DeveloperI just tested it, and it only disables the sticky menu on the home page.
How did you add the function?
July 27, 2017 at 4:51 am #355690ilovemusicHey!
As mentioned above, I used a wordpress plugin called “Code Snippets”Could you tell me how you added it?
I shall re trace your steps!!Cheers!
July 27, 2017 at 8:34 am #355773LeoStaffCustomer SupportThat’s the right method. Is the code added on this site currently? http://demo.ilovemusic.edu.in/
July 29, 2017 at 5:20 am #356617ilovemusicHey Leo,
Its not currently!July 29, 2017 at 5:23 am #356618ilovemusicI shall add it again and see if it works and shall leave it like that for you to check!
Thanks!July 29, 2017 at 5:40 am #356623ilovemusicHey Tom.
So here’s where we have reached so far:My query was : Show sticky menu only on homepage!
– I added the CSS code given by Tom :
body:not(.home) #sticky-navigation,
body:not(.home) #sticky-placeholder {
display: none;
}Result:
SUCESS: The sticky menu now has been deactivated on all pages except my home page.
Problem: Whenever I scroll up or down and return to the top of any other (not my home )page, the primary navigation disappears too.– As Later suggested by Tom add PHP function. :
add_action( ‘wp_enqueue_scripts’,’tu_disable_home_sticky’, 100 );
function tu_disable_home_sticky() {
if ( is_front_page() ) {
wp_dequeue_script( ‘generate-sticky’ );
}
}Result: This function however is only deactivating the sticky on all pages.
End Result: With both, the CSS code and the PHP function added, the sticky menu is disabled on all the pages where as I need to hide the sticky menu only on the home page. Also, on scrolling up and down and then going back to the top, the primary navigation doesn’t reappear.
-
AuthorPosts
- You must be logged in to reply to this topic.