OK, it's a little around the houses but I have at least got a working version of what I need.
What I wanted was to dynamically query from two selects (two taxonomies) either a specific term from each (or both) and ANY term from each (or both). That was why I wanted the 'code / value' for something to put in the arguments for ALL terms.
What I did was run four conditional statements around the values given in from the query strings.
if one select == "all" and the other == "all" then we simply don't need to run the taxonomy query because we a querying everything anyway. So when we have just one taxonomy to query and the other is all, we simply miss it out.
This does feel a little junior, but it does work and seems solid so far.
Here is the code (i put the select values into query strings and read them in)
<!-- BEFORE WE START WE NEED THE POST ID PASSED IN THE QUERY STRING -->
<?php $queryStringValueforState = htmlspecialchars($_GET["state"]); ?>
<?php $queryStringValueforIndustry = htmlspecialchars($_GET["industry"]); ?>
<!-- SEARCH RESULTS -->
<h2>Results for: <?php echo $queryStringValueforState; ?> <?php echo $queryStringValueforIndustry; ?></h2>
<?php
// IF BOTH SELECTS ARE NOT INPUTTED (all)
if ($queryStringValueforState == "All regions" && $queryStringValueforIndustry == "All industries"){
$args = array(
'posts_per_page' => -1,
'post_type' =>'job_listing',
'orderby' => 'ASC'
);
}
// IF BOTH SELECTS HAVE INPUTTED VALUE
if ($queryStringValueforState !== "All regions" && $queryStringValueforIndustry !== "All industries"){
$args = array(
'posts_per_page' => -1,
'post_type' =>'job_listing',
'orderby' => 'ASC',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'job_listing_region',
'field' => 'slug',
'terms' => $queryStringValueforState,
),
array(
'taxonomy' => 'job_listing_category',
'field' => 'slug',
'terms' => $queryStringValueforIndustry,
),
),
);
}
// IF REGION SELECT HAS INPUTTED VALUE AND INDUSTRY HAS NOT
if ($queryStringValueforState !== "All regions" && $queryStringValueforIndustry == "All industries"){
$args = array(
'posts_per_page' => -1,
'post_type' =>'job_listing',
'orderby' => 'ASC',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'job_listing_region',
'field' => 'slug',
'terms' => $queryStringValueforState,
),
),
);
}
// IF INDUSTRY SELECT HAS INPUTTED VALUE AND REGION HAS NOT
if ($queryStringValueforState == "All regions" && $queryStringValueforIndustry !== "All industries"){
$args = array(
'posts_per_page' => -1,
'post_type' =>'job_listing',
'orderby' => 'ASC',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'job_listing_category',
'field' => 'slug',
'terms' => $queryStringValueforIndustry,
),
),
);
}
// END CONDITIONAL STATEMENTS AND CONTINUE WITH LOOP
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="single_job_wrapper">
<div class="job-company-logo"></div>
<div class="job-content">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php echo apply_filters( 'the_job_description', get_the_content() ); ?>
<a class="button" href="<?php the_permalink(); ?>">Read More</a>
</div>
</div>
<?php endwhile; ?>