0

I created a template to display search results based on user selects. The problem is after I click on the search button it sends to the single-product(This is a Product custom post type). I also have the single-product template. Can't figure out what is the problem,I choose the destination,type and duration but after button click it sends to the single-product template even though the action attribute is action="".

Can somebody have any idea what is going on?

Thanks in advance!

                    <form method="GET" action="">
                        <select name="destinations" id="destinations" required="">
                            <option value="" selected disabled hidden>Destinations</option>
                            <option value="destination1" selected>Destination 1</option>
                            <option value="destination2">Destination 2</option>
                            <option value="destination3">Destination 3</option>
                            <option value="destination4">Destination 4</option>
                        </select>
                        <select name="type" id="type" required="">
                            <option value="" selected disabled hidden>Type</option>
                            <option value="adventure">Adventure</option>
                            <option value="cultural">Cultural</option>
                            <option value="family">Family with kids</option>
                            <option value="selfguided">Selfguided</option>
                            <option value="selfdriving">Selfdriving</option>
                        </select>
                        <select name="duration" id="duration" required="">
                            <option value="" selected disabled hidden>Duration</option>
                            <option value="daily">Daily tours</option>
                            <option value="weekends">Weekends</option>
                            <option value="longer">Longer</option>
                        </select>
                        <input type="submit" id="search-btn" name="search" value="Search">
                    </form>
  • Users don’t get sent to templates. That’s not how WordPress works. They get sent to URLs. When the user submits this form, what URL do they end up on? And what URL is the form on to begin with? – Jacob Peattie Jul 2 at 15:10
  • The page where the search code is,the search results should be displayed in that page(same page).But right now when I click the search button it sends me to the the single-product.When search button is clicked I want the results to show on that page.Hope I explained it right.I really need help with this,cause I have no idea what's going on – Testig Content Jul 4 at 14:42
  • @JacobPeattie the url is a specific page i.e. results page with url www.example.com/results and I want when the user clicks search results to be shown on the same page – Testig Content Jul 22 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.