Skip to content

Instantly share code, notes, and snippets.

@mjsdiaz
Created November 24, 2014 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mjsdiaz/8611d44701522565fac2 to your computer and use it in GitHub Desktop.
Save mjsdiaz/8611d44701522565fac2 to your computer and use it in GitHub Desktop.
Open Genesis Primary and Secondary Navigation with a Single Responsive Menu Icon - https://amethystwebsitedesign.com/open-genesis-primary-and-secondary-navigation-with-a-single-responsive-menu-icon/
<?php
//* Do NOT include the opening php tag
/* Edit (or add) the enqueue line for the responsive menu */
//* Enqueue Scripts
add_action( 'wp_enqueue_scripts', 'executive_load_scripts' );
function executive_load_scripts() {
wp_enqueue_script( 'executive-responsive-menu', get_bloginfo( 'stylesheet_directory' ) . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0' );
}
/*
//*Comment out the following in functions.php
//* Remove the site description
remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
//* Reposition the secondary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_footer', 'genesis_do_subnav', 7 );
//* Reduce the secondary navigation menu to one level depth
add_filter( 'wp_nav_menu_args', 'executive_secondary_menu_args' );
function executive_secondary_menu_args( $args ){
if( 'secondary' != $args['theme_location'] )
return $args;
$args['depth'] = 1;
return $args;
}*/
/* Responsive menu code - add to child theme folder /js/ */
jQuery(function( $ ){
$(".genesis-nav-menu").addClass("responsive-menu");
$('<div class="responsive-menu-icon"></div>').insertBefore( '.nav-primary .genesis-nav-menu' );
$(".responsive-menu-icon").click(function(){
$(".genesis-nav-menu").slideToggle();
$(this).toggleClass("menu-open");
});
$(window).resize(function(){
if(window.innerWidth > 800) {
$(".genesis-nav-menu, nav .sub-menu").removeAttr("style");
$(".responsive-menu > .menu-item").removeClass("menu-open");
}
});
$(".responsive-menu > .menu-item").click(function(event){
if (event.target !== this)
return;
$(this).find(".sub-menu:first").slideToggle(function() {
$(this).parent().toggleClass("menu-open");
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment