Adding search toggle to twentysixteen child theme
-
I would like to add the search toggle function from TwentyFourteen to my TwentySixteen child theme. I have the CSS working, and need help with the script to make the search box apper and disapper. I tried copying the search toggle portion of the TwentyFourteen functions.js to a separate fine in my child theme. What am I missing.
Here’s what I copied to the child theme:
( function( $ ) { // Search toggle. $( '.search-toggle' ).on( 'click.child-theme', function( event ) { var that = $( this ), wrapper = $( '#search-container' ), container = that.find( 'a' ); that.toggleClass( 'active' ); wrapper.toggleClass( 'hide' ); if ( that.hasClass( 'active' ) ) { container.attr( 'aria-expanded', 'true' ); } else { container.attr( 'aria-expanded', 'false' ); } if ( that.is( '.active' ) || $( '.search-toggle .screen-reader-text' )[0] === event.target ) { wrapper.find( '.search-field' ).focus(); } } ); } )( jQuery );
- The topic ‘Adding search toggle to twentysixteen child theme’ is closed to new replies.