admin管理员组

文章数量:1426957

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

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

Share Improve this question edited Jun 12, 2019 at 15:25 MikeNGarrett 2,6711 gold badge20 silver badges29 bronze badges asked Jun 12, 2019 at 13:15 Moamen KhedrMoamen Khedr 33 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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/blog/handling-form-submissions/

本文标签: postsHow to invoke a HTML custom button based on a HTML dropdownlist menu