Iยดm making a WordPress website and I want to have a filter on mine search.php file. But whenever I select an option, he brings me back to my homepage instead of being on the same file. I think it has something to do with my url. On the page with the filter, I already have a ?s= in my url. I don’t know how I can fix this in my code that my url has after the ?s= also /?sort=. I don’t if this is even possible, I’m still new to coding.
This is my code (sorry for the ducth words ๐ )
<form method="get" action="<?php echo esc_url(home_url('/')); ?>" class="sortering-form">
<label for="sortering">Sorteer op:</label>
<select name="sort" id="sortering" onchange="this.form.submit()">
<option value="nieuw" <?php selected($_GET['sort'] ?? '', 'nieuw'); ?>>Nieuw โ Oud</option>
<option value="oud" <?php selected($_GET['sort'] ?? '', 'oud'); ?>>Oud โ Nieuw</option>
<option value="titel" <?php selected($_GET['sort'] ?? '', 'titel'); ?>>Titel A โ Z</option>
<option value="random" <?php selected($_GET['sort'] ?? '', 'random'); ?>>Willekeurig</option>
</select>
</form>