Site logo

Archived topic

create a sticky custom menu

4 replies · Started by jasond on September 30, 2019

Viewing posts 1–5 of 5

hello

can you advise how can I create custom menu sticky on the page?

add_action( 'init', function() {
register_nav_menu( 'tour-menu', __( 'Tour Menu' ) );
} );

Thank you

Thanks Tom, is there any way i can add the sticky code directly to the function like what you are doing for generatepres sticky feature? I prefer using native code from the theme rather than installing another plugin

The code in the theme was built specifically for the main navigation, so it's not currently possible to point it elsewhere.

Good idea, though - I'll see if we can make it more extendable :)

There is a workaround for this. You can add your sticky menu items to the main navigation and give it a class name that you can hide in css and only display on the sticky menu when you start scrolling. For example, let's say you name the menu item title "sticky one" and give it a class name of sticky1. Your code would look like this:

.sticky1 {
display: none;
}

#sticky-navigation .sticky1 {
display:block;
}

This archived topic is closed to new replies.