I want to filter my custom posts (pump) with a custom filter form on it’s archive page (archive-pump.php).
So, I wrote the form markup:
<form method="GET">
<label>Series</label>
<?php
if( $terms = get_terms( array( 'taxonomy' => 'series', 'orderby' => 'name' ) ) ) :
echo '<select name="series">';
foreach ( $terms as $term ) :
echo '<option value="' . $term->term_id . '">' . $term->name . '</option>'; // ID of the category as the value of an option
endforeach;
echo '</select>';
endif;
?>
<button type="submit">Apply filter</button>
</form>
And I have this to output my custom posts:
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<?php the_title( '', '', true ); ?>
<?php endwhile; endif; ?>
When I open my page (localhost/project/pumps) it looks fine.
But when I submit my form I’m getting an 404 page.
I maybe need an seperate query to fetch all the $_GET data. But I’m not getting to the step because of the 404 error.
What am I doing wrong? Thank you!