Created
February 5, 2016 06:37
-
-
Save farookibrahim/774419daf7bc8d9128a8 to your computer and use it in GitHub Desktop.
Replace Search bar as dropdown for Nav links in Bethlehem Header 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'init', 'bethlehem_child_init', 10 ); | |
| function bethlehem_child_init() { | |
| // remove nav links on header | |
| remove_action( 'bethlehem_header_3_nav_bar', 'bethlehem_navigation_links', 20 ); | |
| } | |
| if ( ! function_exists( 'bethlehem_primary_navigation' ) ) { | |
| /** | |
| * Display Primary Navigation | |
| * @since 1.0.0 | |
| * @return void | |
| */ | |
| function bethlehem_primary_navigation() { | |
| ?> | |
| <nav id="site-navigation" class="main-navigation" aria-label="<?php _e( 'Primary Navigation', 'bethlehem' ); ?>"> | |
| <button class="menu-toggle"><?php echo esc_attr( apply_filters( 'bethlehem_menu_toggle_text', __( 'Navigation', 'bethlehem' ) ) ); ?></button> | |
| <?php | |
| $container_class = 'primary-navigation'; | |
| if( apply_filters( 'bethlehem_nav_menu_dropdown_animation', 'none' ) != 'none' ) { | |
| $container_class = 'primary-navigation animate-dropdown'; | |
| } | |
| wp_nav_menu( | |
| array( | |
| 'theme_location' => 'primary', | |
| 'container_class' => $container_class, | |
| 'items_wrap' => '<div class="left-nav-menu"><ul class="%2$s">%3$s</ul></div>', | |
| 'walker' => new SplitMenuWalker() , | |
| 'fallback_cb' => 'SplitMenuWalker::fallback', | |
| ) | |
| ); | |
| custom_header_search_block(); | |
| ?> | |
| </nav><!-- #site-navigation --> | |
| <?php | |
| } | |
| } | |
| function custom_header_search_block() { | |
| ?> | |
| <ul class="nav menu nav-menu navbar-nav navbar-right pull-right"> | |
| <li class="dropdown"> | |
| <a class="no-drop-icon dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" href="#"> | |
| <i class="fa fa-search"></i> | |
| </a> | |
| <ul class="sub-menu"> | |
| <form method="get" class="navbar-form search" action="<?php echo esc_url( home_url( '/' ) ); ?>"> | |
| <label class="sr-only screen-reader-text" for="search"><?php echo esc_html__( 'Search for:', 'bethlehem' );?></label> | |
| <input class="form-control" type="search" value="<?php echo esc_attr( get_search_query() ); ?>" name="s" placeholder="<?php echo esc_attr( esc_html__( 'Type to Search', 'bethlehem' ) ); ?>"> | |
| <button class="btn btn-primary btn-submit" type="submit"></button> | |
| </form> | |
| </ul> | |
| </li> | |
| </ul> | |
| <?php | |
| } | |
| // Add the below style to child theme style.css file | |
| /* | |
| .header-3 header.site-header .header-nav-menu .wrap .main-navigation { | |
| display: block !important; | |
| float: none !important; | |
| } | |
| .main-navigation ul.navbar-right li.dropdown:hover > .sub-menu{ | |
| display: block; | |
| } | |
| .main-navigation ul.navbar-right li.dropdown > .sub-menu{ | |
| left: auot; | |
| right: 0; | |
| } | |
| .main-navigation ul.navbar-right li.dropdown > .sub-menu .navbar-form.search { | |
| position: relative; | |
| } | |
| .main-navigation ul.navbar-right li.dropdown > .sub-menu .navbar-form.search input { | |
| padding-right: 40px; | |
| } | |
| .main-navigation ul.navbar-right li.dropdown > .sub-menu .navbar-form.search button { | |
| background: transparent none repeat scroll 0 0; | |
| border: medium none; | |
| font-size: 20px; | |
| height: 25px; | |
| line-height: 1; | |
| margin-right: 2px; | |
| margin-top: 5px; | |
| position: absolute; | |
| right: 10px; | |
| width: 25px; | |
| } | |
| .main-navigation ul.navbar-right li.dropdown > .sub-menu .navbar-form.search button { | |
| display: none; | |
| } | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment