I am setting a WP_Query that runs through all the posts. The example below I want it to show the users selected 'industry', 'access type' and 'location'. This is working perfectly for 'industry' and 'access type' however I have recently added 'location' and it is only showing the scripts from the location.
However I want to show ALL posts in the users selected 'industry' and 'access_type', then I want to show the 'location' as an extra, and not to replace so it just shows posts with the users location. The location is more of an extra.
I have tried using the relation as 'OR' and nested AND within, but this completely breaks.
Could someone please help, very stuck with this!
<?php
$wpb_all_query = new WP_Query(array(
$user_id = $current_user->ID,
$key = 'user_registration_occupation',
$keyi = 'user_registration_industries',
$keyii = 'user_registration_location',
$single = true,
$user_last = get_user_meta( $user_id, $key, $single ),
$user_lasti = get_user_meta( $user_id, $keyi, $single ),
$user_lastii = get_user_meta( $user_id, $keyii, $single ),
'post_type' => array('post', 'case_studies'),
'orderby' => 'publish_date',
'order' => 'DEC',
$string = preg_replace('/[^p{L}p{N}s]/u', '', $user_last),
'category_name' => $string,
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'industry',
'field' => 'slug',
$string2 = preg_replace('/[^p{L}p{N}s]/u', '', $user_lasti),
'terms' => $user_lasti,
),
array(
'taxonomy' => 'access_type',
'field' => 'slug',
'operator' => 'IN',
),
array(
'taxonomy' => 'location',
'field' => 'slug',
$string3 = preg_replace('/[^p{L}p{N}s]/u', '', $user_lastii),
'terms' => $user_lastii,
),
),
'post_status'=>'publish', 'posts_per_page'=>-1));
?>
question from:
https://stackoverflow.com/questions/66066899/wp-query-relation-issue