Site logo

Archived topic

menu customization

37 replies · Started by Jeffrey on July 31, 2020

Viewing posts 16–30 of 38

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 );
} );

ok, 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 :)

no 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?

Tricky 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?

yes 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?

Yea, 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.

Not 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.

You 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.

oh, 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?

or 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;
} );

however, 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 :)

You 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.

Hey 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?"

Add 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;
}
This archived topic is closed to new replies.