0

I have a variable that looks like this

$the_vacancies_industry_areas_list = 'Call Centre','Child Care','Cleaning'

And i want to find if just one of these variables satisfies this case in a meta query

array(
'key' => 'industry_areas_list',
'value' => $the_vacancies_industry_areas_list,
'compare' => 'LIKE',


),

It only seems to satisfy if all three areas are present, not just one.

I want someone with just 'Child Care' or 'Cleaning' for example.

2 Answers 2

2

You need to set the relation type on the wp_query args to OR, then define each of the OR conditions as arrays.

$args = array(
  'meta_query'     => array(
    'relation'  => 'OR',
     array (
       'key'     => 'industry_areas_list',
       'value'   => 'Call Centre',
       'compare' => 'LIKE'
     ),
     array (
       'key'     => 'industry_areas_list',
       'value'   => 'Child Care',
       'compare' => 'LIKE'
     ),
     array (
       'key'     => 'industry_areas_list',
       'value'   => 'Cleaning',
       'compare' => 'LIKE'
     )
);
Sign up to request clarification or add additional context in comments.

Comments

0

Try this: I made $the_vacancies_industry_areas_list as array variable and pass into wp_query

$the_vacancies_industry_areas_list = array('Call Centre','Child Care','Cleaning');

$args = array(
 'post_type' => 'YOUR_POST_TYPE',  //Set your post_type
 'post_status' => 'publish',  //Set your post_status
 'meta_query' => array(
  array(
   'key' => 'industry_areas_list',
   'value' => $the_vacancies_industry_areas_list,
   'compare' => 'IN'
  ),
 ),
);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.