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

In WP_Query, a comma-separated list of term slugs works fine:

$query = new WP_Query ( array(  
     'customtaxonomy' => 'term1,term2'
) );

...but an array of slugs causes a warning:

$query = new WP_Query ( array(  
     'customtaxonomy' => array( 'term1', 'term2' )
) );

Warning: urlencode() expects parameter 1 to be string, array given in /path/to/wp-includes/formatting.php on line 3253

Another WPSE post proposes that this could be WP looking for hierarchy in a hierarchical taxonomy, but I can't think of any way to make sense of this behaviour. Do you know why this is happening?

share|improve this question

If you read the codex page carefully, you will see that taxonomy parameter {tax} (in your case it is customtaxonomy) takes only string value. Furthermore such taxonomy parameter is deprecated from version 3.1. So in your case you have to pass tax_query array with terms array:

$query = new WP_Query ( array(  
    'tax_query' => array( 
        'terms' => array( 'term1', 'term2' )
) );
share|improve this answer
Interesting, I didn't realize that the taxonomy parameter is deprecated. Tangentially, writing a query string that would be parsable into tax_query seems quite complicated, if possible at all. (For example, I use a post listing shortcode with a query parameter.) – supertrue Feb 21 '13 at 22:28
@supertrue it is good habit to read the codex first... ;) – Eugene Manuilov Feb 21 '13 at 22:38

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.