0 isn’t a valid term ID in a tax query. Don’t add the category tax query parameters if the value is 0, which is equivalent to ignoring category. If you want only posts that are categorized (a category must be assigned, but it can be any category), then use the EXISTS
operator.
$tax_query = '';
if( isset($_GET['cat']) && 0 != $_GET['cat'] ) {
$tax_query[] = array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => $_GET['cat']
);
}
if( isset($_GET['manufacturer']) && 0 != $_GET['manufacturer'] ) {
$tax_query[] = array(
'taxonomy' => 'manufacturers',
'field' => 'term_id',
'terms' => $_GET['manufacturers']
);
}
// only add relation if both are set and non-zero
if( isset($_GET['manufacturer']) && 0 != $_GET['manufacturer'] && isset($_GET['cat']) && 0 != $_GET['cat'] ) {
$tax_query['relation'] = 'AND';
}
// query args for all queries
$query_args = array(
'post_type' => 'yacht',
// other args...
);
// add tax query if it isn't empty
if( !empty( $tax_query ) ){
$query_args['tax_query'] = $tax_query;
}
$yacht_query = new WP_Query( $query_args );