Mobile Menu Doesn’t Expand
-
Hi,
I created a child theme for Twentyseventeen, I added my custom CSS to the Child Theme CSS and enqueued original CSS from Tventyseventeen. I am almost done with the website but I have this issue with the mobile menu that works only on the Homepage.When I go to the other pages, the mobile menu doesn’t expand. I tried to turn all the plug-ins on and off, one by one, tried the z-index fix, nothing worked.
It seems like this class
button.toggle-menu-on, doesn’t even trigger jquery event on the other pages, and I cannot seem to find where the glitch is.Please help me out!
Here is the link to my production website: http://bpositive.heistdc.com
-
The JavaScript relies on a certain HTML structure, such as there being a wrapping element with the ID of ‘masthead’:
masthead = $( '#masthead' ); menuToggle = masthead.find( '.menu-toggle' ); siteNavContain = masthead.find( '.main-navigation' ); siteNavigation = masthead.find( '.main-navigation > div > ul' );The pages that contain the problem do not have an element with the masthead structure
-
This reply was modified 8 years, 11 months ago by
Andrew Nevins.
-
This reply was modified 8 years, 11 months ago by
Andrew Nevins.
Hi Andrew,
Thanks for a quick reply.Can you please help me to find the template part which dislays other pages?
Should be the page.php?I’ve realized what you’re saying, the HTML structure changes on the other pages, except the Homepage.
#mastheadshould be wrap around ‘navigation-top’ as it’s in the proper HTML that displays the Homepage, but I cannot figure out how is this happening since the code for theheader #mastheadis inheader.php.
Supposedly it should be the same on every page?-
This reply was modified 8 years, 11 months ago by
stojax777.
Hi again,
I went back through the template parts that I’ve changed and the only one was the
site-branding.phpThis was my code to show the
custom-headerand the call-to-action button that I created next to the logo.<?php /** * Displays header site branding * * @package WordPress * @subpackage Twenty_Seventeen * @since 1.0 * @version 1.0 */ ?> <?php if ( is_front_page() ) : ?> <div class="site-branding"> <div class="wrap"> <div class="site-branding-text"> <?php if ( is_front_page() ) : ?> <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1> <?php else : ?> <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p> <?php endif; ?> <?php $description = get_bloginfo( 'description', 'display' ); if ( $description || is_customize_preview() ) : ?> <p class="site-description"><?php echo $description; ?></p> <?php endif; ?> </div><!-- .site-branding-text --> <?php if (is_front_page() ) : //This displays Book Now Button only on the front page?> <div id="call-book-now"> <!-- this is a separate div created for a BOOK NOW button--> <?php the_custom_logo(); ?> <a href="#form"> <button type="button" id="submit" class="special-button">RESERVE YOUR TABLE</button> </a> </div> <?php else : ?> <!--continue the wrap div--> <?php endif; ?> <?php if ( ( twentyseventeen_is_frontpage() || ( is_home() && is_front_page() ) ) && ! has_nav_menu( 'top' ) ) : ?> <a href="#content" class="menu-scroll-down"><?php echo twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ); ?><span class="screen-reader-text"><?php _e( 'Scroll down to content', 'twentyseventeen' ); ?></span></a> <?php endif; ?> </div><?php endif; ?><!-- .wrap --> </div><!-- .site-branding -->Now the menu works on every page, but I also have
custom-headerappearing on every page, any ideas how to get rid of thecustom-headeron other pages.I tried through CSS class
body:not(.home-page).custom-header{ visibility: hidden !important; }but that didn’t work out!
Please help!
Hi @stojax777,
use php and WordPress functions to print custom-header only in homepage<?php if ( is_front_page() ) : ?> <div class="custom-header"> </div> <?php endif; ?>you can also decide what pages you want the tags to be displayed like this:
<?php if ( is_page(20) ) : ?> <div class="custom-header"> </div> <?php else if(is_page(array('30', '40', '50'))) : ?> <div class="another-custom-header"> </div> <?php endif; ?>you can do the same in articles too
<?php if ( is_single(20) ) : ?> <div class="custom-header"> </div> <?php else if(is_single(array('30', '40', '50'))) : ?> <div class="another-custom-header"> </div> <?php endif; ?>the numbers are page ids
hope it helps you have a nice day
-
This reply was modified 8 years, 11 months ago by
riangraphics.
-
This reply was modified 8 years, 11 months ago by
riangraphics.
Thanks a lot @riangraphics,
I added the code to the
header.phpinstead tosite-branding.phpand it totally solved my problem.Hi again,
I solved the
custom headerproblem, but now I cannot log into the wordpress using wp-admin?Anyone has any suggestions?
This how my
header.phplooks like:<?php /** * The header for our theme * * This is the template that displays all of the <head> section and everything up until <div id="content"> * * @link https://developer.ww.wp.xz.cn/themes/basics/template-files/#template-partials * * @package WordPress * @subpackage Twenty_Seventeen * @since 1.0 * @version 1.0 */ ?><!DOCTYPE html> <html <?php language_attributes(); ?> class="no-js no-svg"> <head> <meta charset="<?php bloginfo( 'charset' ); ?>"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="profile" href="http://gmpg.org/xfn/11"> <?php wp_head(); ?> </head> <body <?php body_class(); ?>> <div id="page" class="site"> <a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'twentyseventeen' ); ?></a> <header id="masthead" class="site-header" role="banner"> <?php if ( is_front_page() ) : ?> <?php get_template_part( 'template-parts/header/header', 'image' ); ?> <?php endif; ?> <?php if ( has_nav_menu( 'top' ) ) : ?> <div class="navigation-top"> <div class="wrap"> <?php get_template_part( 'template-parts/navigation/navigation', 'top' ); ?> </div><!-- .wrap --> </div><!-- .navigation-top --> <?php endif; ?> </header><!-- #masthead -->what error do you get while trying to access wp-admin?
Hi @riangraphics,
I actually don’t get to load the page at all. Only a blank screen.
I don’t understand how this happened, since this has nothing to do with theheader.phpthat I modified.i can access your wp-admin with no problem
http://bpositive.heistdc.com/wp-login.php?redirect_to=http%3A%2F%2Fbpositive.heistdc.com%2Fwp-admin%2F&reauth=1-
This reply was modified 8 years, 11 months ago by
riangraphics.
I am sorry, forgot to mention that it works on the provided address.
It stopped working on my local environment where I’m implementing the modifications to the website, before putting files on the production server.Guess I’ll just strip down the
wp-admin folderfrom the production server back to my local server. -
This reply was modified 8 years, 11 months ago by
The topic ‘Mobile Menu Doesn’t Expand’ is closed to new replies.
