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!
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];