• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Add Sticky Menu to Genesis Magazine Pro

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add Sticky Menu to Genesis Magazine Pro

This topic is: not a support question
  • This topic has 1 reply, 2 voices, and was last updated 6 years, 9 months ago by Victor Font.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • March 11, 2019 at 11:50 am #489941
    MikeB2
    Member

    I tried 10-12 different combinations of PHP, JS, and CSS code before finding the right set of code to fix the navigation menu to the top of the page on scroll. This forum had no workable solutions so I'm posting a solution here.

    It came from "STICKY MENU NAVIGATION IN GENESIS" by Katrina at Riot Customs.
    https://riotcustoms.com/sticky-wordpress-navigation-menu/

    I had to modify the JS and CSS code since the website I was targeting uses the nav-secondary menu instead of nav-primary.

    Add to the theme's functions.php:

    add_action( 'wp_enqueue_scripts', 'riot_enqueue_script' );
    function riot_enqueue_script() {
    	wp_enqueue_script( 'sticky-nav', get_bloginfo( 'stylesheet_directory' ) . '/js/sticky-nav.js', array( 'jquery' ), '', true );
    }

    Add this sticky-nav.js file to the js folder in your theme directory. (Note: here is where you will need to change the name of the menu if you are not using nav-primary.)

    jQuery(document).ready(function($) {
            var $filter = $('.nav-primary');
            var $filterSpacer = $('<div />', {
                    "class": "filter-drop-spacer",
                    "height": $filter.outerHeight()
            });
     
     
            if ($filter.size())
            {
                    $(window).scroll(function ()
                    {
                            if (!$filter.hasClass('fix') && $(window).scrollTop() > $filter.offset().top)
                            {
                                    $filter.before($filterSpacer);
                                    $filter.addClass("fix");
                            }
                            else if ($filter.hasClass('fix')  && $(window).scrollTop() < $filterSpacer.offset().top)
                            {
                                    $filter.removeClass("fix");
                                    $filterSpacer.remove();
                            }
                    });
            }
    });

    Add this code to your theme's style.css file. Again, you will need to change the menu name if not using nav-primary.

    /* Sticky Primary nav */
    .nav-primary.fix {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1000;
        width: 100%;
        max-width: 100%;
        overflow: visible;
        background: rgba(255, 255, 255, 0.92);
    }
    
    .admin-bar .nav-primary.fix {
        top: 28px;
    }
    March 11, 2019 at 12:39 pm #489949
    Victor Font
    Moderator

    Thanks for posting this tip.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Add Sticky Menu to Genesis Magazine Pro’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble