WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
  'taxonomy' => $taxonomy_array_value,          
  'field' => 'slug',
  'terms' => array( $term_name )

This is my code where $taxonomy_array_value and $term_name are variables coming from ajax.

First Case :
$taxonomy_array_value = Colors and $term_name = 'red' then WP_Query is working fine.

Second Case :
$taxonomy_array_value = Colors and %term_name = 'red','green' but in this case it's not working.

While instead of using variable if I direct pass 'red','green' in 'terms' then it's working fine but not working with variable Don't know why.

Here is my code from which I am getting $term_name

$term_name = "'" . implode("','", $term_value_array) . "'";
share|improve this question
Please reformat your question. Thanks. – kaiser May 26 '13 at 12:49
up vote 1 down vote accepted


'terms' => $term_value_array

instead of

'terms' => array( $term_name )

It looks like the problem is that you use array("'red','green'") instead of the array structure: array('red','green') that you want.

share|improve this answer
Thanks for answer and you know what I already did it before your answer and another thing that you answered in my one other question Thanks for that Thankyou so much. – Bhuvnesh Gupta May 26 '13 at 12:24
great to hear it worked out for you, good luck with your project. – birgire May 26 '13 at 12:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.