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

I have posted a question on StackOverflow (sorry for the cross link) and while I'm striving to find a solution to this, I stumbled across this warning :

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

And doing a backtrace, I find it originates in query.php :

wp_includes/query.php, lines 1710...1712

if ( isset( $t->rewrite['hierarchical'] ) && $t->rewrite['hierarchical'] ) {
     $q[$t->query_var] = wp_basename( $q[$t->query_var] );

Now, I get this error because one of my URL param is an array of categories, where I'm trying to search and return all product (custom post type) that has one or more of the defined categories assigned.

Why is WordPress trying to call basename on an array of GET parameter is beyond me. Anyone care to explain this to me? Thanks!

share|improve this question
up vote 3 down vote accepted

I'm not sure exactly what's happening, but I can guess based on a few context clues. That particular function is parse_tax_query. It appears to be checking if the taxonomy is hierarchical, I assume it's expecting a string that could possibly be a parent/child path of terms, so it uses basename to get the actual term queried- the next line is $term = $q[$t->query_var];

share|improve this answer
And what's the solution? I am having the same 'issue' when creating new WP_Query. – Radek Aug 22 '13 at 6:08
So the correct syntax that works for me in WP 3.6 is 'category__in' => $category where $category is an array. – Radek Aug 22 '13 at 6:22

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.