Search bar in primary menu

  • Author
    Posts
  • #27778
    Bembis

    There is search bar in top menu and even there is “search bar locations” (select the menus where to add a search bar) option in Nirvana settings. So are You planning to implement search bar in more locations not just in top menu in near future? Maybe even in 1.0.0 version? (just kidding) 🙂

    #27861
    Bembis

    If someone needs search bar in primary menu and they can’t wait when that option is going be in Nirvana settings, you could implement search bar for yourself.

    Paste this code into childs function.php

    add_filter('wp_nav_menu_items','add_search_box_to_nav_menu', 10, 2);
    function add_search_box_to_nav_menu( $items, $args ) {
        if( $args->theme_location == 'primary' )
            return $items.get_search_form();
    
        return $items;
    } 

    After that you need a style search form a little bit in childs style.css, but that its easy. You could style search bar in style.css by nav#access form#searchform.
    Example:

    nav#access form#searchform {
    float: right;
    padding-top: 5px;
    right: 15px;
    max-width: 200px;
    }
    
    nav#access #searchform:after {
    top: 5px;
    }
    
    nav#access #searchsubmit {
    top: 5px;
    }
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Search bar in primary menu’ is closed to new replies.