0
<select name="sort-posts" id="sortbox" name="sortbox">
    <option value="" disabled>Sort by</option>
    <?php
        $categories = get_categories(['exclude' => 1]);
        foreach ($categories as $category) {
            echo "<option>$category->name </option>";
        }
    ?>
    <option>Newest</option>
    <option>Oldest</option>
    <option>Title Asc</option>
    <option>Title Desc</option>
</select>

And I want to get the value of the selected option without redirecting or using form, for me to use it in function.

How can I do that?

MikO
  • 18,243
  • 12
  • 77
  • 109

0 Answers0