I have made some progress on this issue, but I still need a little assistance in expanding the hamburger menu on mobile HOMEPAGE only. The site is now live and I’m tweaking as I go – alabamaguntrader.net
First off, I asked a friend of mine how he would do automatically expand the mobile menu and he said to just add some javascript or jQuery to do that. So I did that with jQuery (which was a learning experince) and it worked.
But now I have found that the auto-expanded menu gets in the way when you are not on the hompage and trying to do other stuff on the site. So I tried
1)Adding an if condition in the functions file around the “add_action” that runs the jQuery. Menu is no longer auto expanding on any mobile page:
if ( is_front_page() ) {
add_action( ‘wp_enqueue_scripts’,’expand_mobile_menu_by_default_on_homepage’ );
}
2)Tried adding the if condition in the jQuery like this. Menu no longer expands on any mobile page…
if (jQuery(location).attr(‘alabamaguntrader.net’); ) {
jQuery(‘.secondary-toggle’).trigger(‘click’);
}
I also tried this in the jQuery file to no effect:
if ( jQuery(location).attr(‘href’) == ‘http://www.alabamaguntrader.net’) {
//click the hamburger menu
jQuery(‘.secondary-toggle’).trigger(‘click’);
}
Here is the reference page I’m using for this code:
http://stackoverflow.com/questions/406192/get-current-url-in-javascript