0

I am a WordPress beginner and want a help

I created a HTML dropdown list like this:

<select name="DropDownList1" id="DropDownList1">
    <option value="select you location">&#xf015 select your location</option>
    <option value="cairo">Cairo</option>
    <option value="alexanderia">Alexanderia</option>
    <option value="aswan">Aswan</option>
    <option value="port said">Port Said</option>
</select>

and also I created a HTML button like this:

<button type="button" name="restaurantpreview" type="submit" value="chefpreview">restaurantpreview</button>

I am trying to search about the code that I must use to :

  • when a user select a value from dropdown list

  • then the user click on my button

  • I get this value to my custom page and preview the list of restaurants in it

0

You want to use admin-post.php or admin-ajax.php (AJAX only) to allow your front-end form to interact with WordPress.

Setting this up will allow you to create an action where you use the $_POST array to find the content you're looking for with WP_Query and print it out as the response to your request.

Here's a decent guide to both methods: https://premium.wpmudev.org/blog/handling-form-submissions/

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.