How to add a search bar in the top menu in Zelle

As we always recommend to everyone, please make sure that you're using a child theme with your Zelle theme.

In your child theme, add the following snippet just above ?> closing tag or in the end of the functions.php file if there is no closing tag:

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

For adding the search field into the main menu, use the following code instead of the above one

function add_search_box( $items, $args ) {

   if( $args->theme_location == 'primary' ) {

         $items .= '<li class="widget widget_search" style="margin-top: 15px">' . get_search_form( false ) . '</li>';

         return $items;

   }
}
add_filter( 'wp_nav_menu_items','add_search_box', 10, 2 );
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.