• Hi,

    I am running WordPress on my own server and have made a number of modifications and am fairly well versed in HTML and CSS,but am getting a little stuck when it comes to solving this particular issue.

    Basically,I want to have the Menu Toggle Button which is native to to the Twenty Sixteem theme so it displays at all times at all screen resolutions and the menu is permanently collapsable,rather than just at certain screen sizes.

    I assume this is something to do with the media queries involved in calling the button.

    As ever,any help would be greatly appreciated.

Viewing 15 replies - 1 through 15 (of 89 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    You need to do a couple of things:
    – Dequeue the theme’s functions.js file and enqueue your own (so that you can modify it)
    – Override the parent theme styles that control the theme’s navigation menu.

    First set up a Child Theme: https://codex.wordpress.org/Child_Themes

    Thread Starter Wolfman1000

    (@wolfman1000)

    Hi,

    Thanks for the reply.

    I’ve already made a child theme and made the changes so far that I need to the header.php and footer.php files I copied into my child theme.

    I’ve managed to move the Menu below the header image and simply now just need to get the menu toggle so it permanently replaces the navigation menu at ALL screen sizes and position it correctly.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Let’s start with dequeuing the parent theme’s functions.js file: https://codex.wordpress.org/Function_Reference/wp_dequeue_script

    The handle is:

    twentysixteen-script

    Thread Starter Wolfman1000

    (@wolfman1000)

    OK.

    The Javascript stuff is kind of getting out of my skillset a bit but I’ll certainly give it a try!

    Where do we do this?In the functions.js file in the child theme?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Open up your Child Theme functions.php file and write this line of PHP:

    wp_dequeue_script( 'twentysixteen-script' );

    Thread Starter Wolfman1000

    (@wolfman1000)

    I will do…at the top of the file?

    Thread Starter Wolfman1000

    (@wolfman1000)

    So I’ve done that,and everything seems to be functioning as normal…which is good!

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Doesn’t matter where really, as long as it’s between the <?php and ?> tags

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Make a copy of the theme’s functions.js file (in the “js” folder) and put that copy inside of your Child Theme folder. Let’s not create a “js” folder inside your Child Theme folder.

    Then in your Child Theme functions.php file, add these lines of code:

    function wpdocs_theme_name_scripts() {
        wp_enqueue_script( 'twentysixteen-child-script', get_stylesheet_directory_uri() . '/functions.js', array(), '1.0.0', true );
    }
    add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' )

    https://developer.wordpress.org/reference/functions/wp_enqueue_script/

    And then you can modify your Child Theme functions.js file.

    You want to change this:

    if ( window.innerWidth < 910 ) {
    			if ( menuToggle.hasClass( 'toggled-on' ) ) {
    				menuToggle.attr( 'aria-expanded', 'true' );
    			} else {
    				menuToggle.attr( 'aria-expanded', 'false' );
    			}
    
    			if ( siteHeaderMenu.hasClass( 'toggled-on' ) ) {
    				siteNavigation.attr( 'aria-expanded', 'true' );
    				socialNavigation.attr( 'aria-expanded', 'true' );
    			} else {
    				siteNavigation.attr( 'aria-expanded', 'false' );
    				socialNavigation.attr( 'aria-expanded', 'false' );
    			}
    
    			menuToggle.attr( 'aria-controls', 'site-navigation social-navigation' );
    		} else {
    			menuToggle.removeAttr( 'aria-expanded' );
    			siteNavigation.removeAttr( 'aria-expanded' );
    			socialNavigation.removeAttr( 'aria-expanded' );
    			menuToggle.removeAttr( 'aria-controls' );
    		}

    To this:

    if ( menuToggle.hasClass( 'toggled-on' ) ) {
    				menuToggle.attr( 'aria-expanded', 'true' );
    			} else {
    				menuToggle.attr( 'aria-expanded', 'false' );
    			}
    
    			if ( siteHeaderMenu.hasClass( 'toggled-on' ) ) {
    				siteNavigation.attr( 'aria-expanded', 'true' );
    				socialNavigation.attr( 'aria-expanded', 'true' );
    			} else {
    				siteNavigation.attr( 'aria-expanded', 'false' );
    				socialNavigation.attr( 'aria-expanded', 'false' );
    			}
    
    			menuToggle.attr( 'aria-controls', 'site-navigation social-navigation' );

    Thread Starter Wolfman1000

    (@wolfman1000)

    Yep,check.Done that.

    Thread Starter Wolfman1000

    (@wolfman1000)

    Ok just checking this out now…

    Thread Starter Wolfman1000

    (@wolfman1000)

    I’ve done that,I think…….no change on the site currently though.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Now in your Child Theme style.css file, add this CSS:

    .menu-toggle, .top-menu-toggle {
        display: block;
    }
    
    .main-navigation ul {
        display: none;
    }

    Thread Starter Wolfman1000

    (@wolfman1000)

    Got ya….

    Thread Starter Wolfman1000

    (@wolfman1000)

    So that’s worked,and removed the UL nav list and is now displaying the toggle.Seems like a good way to do it as I can easily change the CSS if I change my mind.However,the toggle no longer actually brings up the menu items…

Viewing 15 replies - 1 through 15 (of 89 total)
  • The topic ‘Twenty Sixteen Theme- Having Menu button Permanent’ is closed to new replies.