- This topic has 37 replies, 3 voices, and was last updated 3 years, 8 months ago by David.
-
AuthorPosts
-
August 2, 2020 at 9:57 am #1384945TomLead DeveloperLead Developer
Try this:
add_filter( 'option_generate_menu_plus_settings', function( $options ) { if ( is_singular( 'product' ) ) { $options['sticky_menu'] = 'false'; $options['mobile_header'] = 'enable'; $options['mobile_header_sticky'] = 'enable'; $options['mobile_header_auto_hide_sticky'] = 'false'; } return $options; } );
To fix the sticky issue, you could try this:
add_action( 'wp', function() { remove_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 7 ); add_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 8 ); } );
August 2, 2020 at 10:21 am #1384956Jeffreyok, I implemented the code.
The main nav is still sticky, and it moved the sub menu below the header element. Seems to have separated the menus in some way. Maybe you can check the products page to see?
Really appreciate the php help ๐
August 2, 2020 at 1:21 pm #1385069TomLead DeveloperLead DeveloperJust tweaked the code a bit, can you give it another try?: https://generatepress.com/forums/topic/menu-customization-3/page/2/#post-1384945
August 2, 2020 at 2:08 pm #1385098Jeffreyno go, still in the same spots.. left it up and added a page if that helps. Is there anything my green thumb can do to help?
August 3, 2020 at 9:48 am #1386011TomLead DeveloperLead DeveloperTricky one as I haven’t left a lot of room to breathe with the priorities in the plugin. Just made another tweak to the second function above – better?
August 3, 2020 at 10:39 am #1386082Jeffreyyes better, but just really back to the default behavior. When I disable the snippets it seems to be the same. Maybe it wont be possible the way its written? If not, could I pay for a rewrite from you possibly?
August 3, 2020 at 12:38 pm #1386236TomLead DeveloperLead DeveloperYea, that method won’t work unfortunately. The issue is coming from the merged header – is it necessary on this page? If you un-merge the header, it should work as-is.
August 3, 2020 at 1:11 pm #1386283JeffreyNot necessary, totally down to un-merge the header for the page to work right, which version of the code should I use though, tried the last one as is, and no go.
August 3, 2020 at 1:15 pm #1386286TomLead DeveloperLead DeveloperYou shouldn’t need the second function at all if you un-merge the header. You’ll just need the code that David gave you, and the updated first function I provided above.
August 3, 2020 at 1:41 pm #1386295Jeffreyoh, maybe the problem is that I made a custom product page.
It is working on the product page itself and looks awesome (if you click the sub nav product/book), but I also want it to work on any and all pages I add submenus too. Is that possible?
August 3, 2020 at 2:59 pm #1386342Jeffreyor I figured I could do this…and it only displays on pages specified.
add_filter( 'option_generate_menu_plus_settings', function( $options ) { if ( is_page( array( 375, 522 ) ) ) { $options['sticky_menu'] = 'false'; $options['mobile_header'] = 'enable'; $options['mobile_header_sticky'] = 'enable'; $options['mobile_header_auto_hide_sticky'] = 'false'; } return $options; } );
August 3, 2020 at 4:01 pm #1386364Jeffreyhowever, it moves the header image down which is normal i assume. Is there a way to have the header element directly under the main navigation as if the secondary was not there. I’m using a transparent background kinda thing.
And the above code works on pages, but what if I wanted to have it also work on the product pages, like you had it?
and..
Just noticed the woocomerce site-wide notice now overlaps the primary navigation, is there a way to move that on top again?
Sorry for all the edits ๐
August 4, 2020 at 6:49 am #1386865DavidStaffCustomer SupportYou can use the
||
OR operand in your condtion. This will apply to Product or those specific pages.if ( is_singular( 'product' ) || is_page( array( 375, 522 ) ) ) {
You can use this CSS to move the header element up if the secondary nav is present:
.secondary-navigation + .page-hero { margin-top: -62px; }
You will need to ensure the header element has sufficient padding/quite space so the nav doesn’t overlap its content.
August 4, 2020 at 6:51 am #1386867JeffreyHey I just added to that last message sorry I will implement the above now.
“Just noticed the woocomerce site-wide notice now overlaps the primary navigation, is there a way to move that on top again?”
August 4, 2020 at 7:16 am #1386886DavidStaffCustomer SupportAdd this snippet to move the notice above the header:
add_action( 'after_setup_theme', function() { remove_action( 'wp_footer' , 'woocommerce_demo_store', 10); add_action( 'generate_before_header' , 'woocommerce_demo_store' , 1); });
And this CSS to stop it overlapping:
.woocommerce-store-notice, p.demo_store { position: static; }
-
AuthorPosts
- You must be logged in to reply to this topic.