[Support request] create a sticky custom menu

Home Forums Support [Support request] create a sticky custom menu

Home Forums Support create a sticky custom menu

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1022727
    jasond

    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

    #1022892
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    That code will register a new menu location, but it won’t do anything else.

    Maybe a Navigation Widget along with a plugin like this would help?: https://wordpress.org/plugins/sticky-menu-or-anything-on-scroll/

    #1022957
    jasond

    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

    #1023577
    Tom
    Lead Developer
    Lead Developer

    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 🙂

    #1381225
    concepts123

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

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.