Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add sticky menu to the Genesis Sample theme.
<?php
//* Do NOT include the opening php tag
//* Enqueue sticky menu script
add_action( 'wp_enqueue_scripts', 'custom_enqueue_script' );
function custom_enqueue_script() {
wp_enqueue_script( 'sticky-menu', get_stylesheet_directory_uri() . '/js/sticky-menu.js', array( 'jquery' ), '', true );
}
//* Reposition the secondary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_before', 'genesis_do_subnav' );
jQuery(function( $ ){
$(window).scroll(function() {
var yPos = ( $(window).scrollTop() );
if(yPos > 200) { // show sticky menu after screen has scrolled down 200px from the top
$("#subnav").fadeIn();
} else {
$("#subnav").fadeOut();
}
});
});
/*
Sticky Menu
---------------------------------------------------------------------------------------------------- */
#subnav {
background-color: #1e1e1e;
display: none;
position: fixed;
top: 0;
width: 100%;
z-index: 999;
}
#subnav .wrap {
margin: 0 auto;
position: relative;
width: 1152px;
}
#subnav .genesis-nav-menu.menu-secondary {
border: none;
}
.genesis-nav-menu.menu-secondary a {
color: #fff;
padding: 20px;
padding: 1.25rem;
}
.genesis-nav-menu.menu-secondary li.sticky-right {
float: right;
}
.genesis-nav-menu.menu-secondary li li a,
.genesis-nav-menu.menu-secondary li li a:link,
.genesis-nav-menu.menu-secondary li li a:visited {
background-color: #1e1e1e;
border: 1px solid #fff;
border-top: none;
color: #fff;
padding: 20px;
padding: 1.25rem;
}
.genesis-nav-menu.menu-secondary li li a:hover {
color: #ff2a00;
}
@minhkhoiwp

This comment has been minimized.

Copy link

minhkhoiwp commented Jan 10, 2018

do not active https://minhkhoi.net/

@bbqqueens

This comment has been minimized.

Copy link

bbqqueens commented Aug 26, 2018

I do not use for my website: https://www.bbqqueens.com/ , i must use plugin: myStickymenu to add sticky menu :'(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.