Home Support Themes ListingHive Hivepress listing search form in Header?

Hivepress listing search form in Header?

  • Author
    Posts
  • keymaker

    Hello Hivepress,

    Firstly – what an amazing project! I will definitely contribute in the coming weeks!

    Secondly, I am trying to figure out how I can add the Hivepress Listing Search Form into the header-navbar? I have found this filter snippet:

    add_filter( 'wp_nav_menu_items','add_search_box', 10, 2 );
    function add_search_box( $items, $args ) {
    $items .= '<li>' . get_search_form( false ) . '</li>';
    return $items;
    }

    This of course, pulls in a generic search form… and that’s where my knowledge falls over.

    Ultimately, I want the header-navbar, inside a container (.header-navbar container), separated into 3 columns – first column = logo, second column = Hivepress Listing Search Form, third column with navbar menu items.

    Can anyone help me figure this out?

    Thank you all for your time.
    Chris

    ihor developer

    Thanks, glad you like it!
    If only the keywords field is required, you can simply add this to the search form:
    <input type="hidden" name="post_type" value="hp_listing">
    Or you can use this snippet instead:

    add_filter( 'wp_nav_menu_items','add_search_box', 10, 2 );
    function add_search_box( $items, $args ) {
    $items .= '<li>' . do_shortcode('[hivepress_listing_search_form]') . '</li>';
    return $items;
    }

    But it requires additional styling, since this form is too large for the header section. You can customize the header section (set 3 columns or make other changes) by copying header.php file to the child theme folder.

    keymaker

    Thank you so much ihor – the string snippet is exactly what I was after, and I can do the styling/child theme/header.php file.

    Thank you and all the best.

    Chris

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Hivepress listing search form in Header?’ is closed to new replies.