• The search-bar on my website doesn’t work, it doesn’t load anything, it just re-loads homepage. Here is the code that I use:

    <form role="search" method="get" class="homePageBanner__content__form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
                            <div class="form-group">
                            <div class="row">
                                <div class="col-3 col-md-2">
                                    <select class="selectStyle">
                                    <?php
                                    $categories = get_categories();
                                    foreach ($categories as $category) {
                                        $option = '<option value="' . $category->slug . '">';
                                        $option .= $category->cat_name;
                                        $option .= '</option>';
                                        echo $option;
                                    }
                                    ?>
                                </select>
                            </div>
    
                                <div class="col-5 col-md-7 px-0">
                                <input type="text" name="s" id="search" placeholder="Search" class="searchBoxStyle ps-4 border-start border-1">
                            </div>
                                <div class="col-4 col-md-3">
                                <input type="submit" value="Search" placeholder="Search For WallPapers" class="searchButtonStyle">
                                </div>
                            </div><!-- row -->
                            </div><!-- Form Group -->
Viewing 3 replies - 1 through 3 (of 3 total)
  • kingscrownsolutions

    (@kingscrownsolutions)

    Can you be more specific on what is your domain, if we can see live version or where have you inserted this code?

    is there a search.php file in your theme? Observe your action form. The url of the action attribute is the home page. At the same time, the select has no name attribute.

    Thread Starter ferdalkrmn

    (@ferdalkrmn)

    I found the problem, the loop was missing this:
    ‘s’ => get_search_query()

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Searc-bar doesn’t work.’ is closed to new replies.