I have a list of taxonomy terms with checkboxes that post as an array on form submit to a page template called Post List. My goal here is to list taxonomy terms with checkboxes, then on form submit, display the corresponding posts that have the checked terms assigned to them e.g.
<?php
$terms = get_terms("the_taxonomy");
$count = count($terms);
if ( $count > 0 ){?>
?>
<form action="<?php echo esc_url( get_permalink( get_page_by_title( 'Post List' ) ) ); ?>" method="post">
<?php foreach ( $terms as $term ) {?>
<input type="checkbox" name="terms[]" value="<?php echo $term->name ?>" /><?php echo $term->
name ?> <br />
<?php }?>
<input type="submit" value="Submit" />
</form>
When I print the array within Post List page (post-list.php), I do get the returned terms, so I can confirm that it works
<?php
/*
Template Name: Post List
*/
?>
<?php print_r($_POST['terms']);?>
<!---OUTPUT--->
Array ( [0] => term1 [1] => term2 [2] => term3 [3] => term4 )
How could I compare the returned terms array to the stored terms of the custom post type, and return posts based off of which terms were selected and submitted? Thanks for your help.