There is a wordpress filter on the site page that displays data depending on age on the same page.
I give the full code of the filter:
<form action="" method="post"> <label class="ages">Введите возраст: <input type="number" name="age"/> </label> <button type="submit">Найти</button> </form> <div> <?php $args = array ( 'post_type' => 'method', 'posts_per_page' => '-1', 'relation' => 'AND', 'meta_query' => array( 'key' => 'age_min', 'value' => (int) $_POST["age"], 'type' => 'numeric', 'compare' => '<=' ), ); $the_query = new WP_Query( $args ); while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <div class="name"><?php the_title(); ?></div> <?php endwhile; wp_reset_postdata(); ?> </div> How to do so, when clicking a button on the <button>Очистить результат</button> , the results were reset and returned to the initial position like:
if (isset($_POST['age'])) { unset($_POST['age'])); } UPD: there is a solution, but it is incomplete - you need to send the same form with an empty value
<form action="" method="post"> <button type="submit" name="age" value="">Очистить результат</button> </form> , but there is a nuance: $_POST['age'] can be set to 0 , and value="" is equated to it and now the filter is triggered by zero
<input type="button" value="Очистить результат" onclick="getElementsByName('age')[0].value = ''">but no .. - Vasya$_POST['age']after sending - Vasya