【发布时间】:2015-03-19 17:39:29
【问题描述】:
我正在向 Wordpress 搜索表单添加一些自定义过滤,允许用户按不同的分类进行过滤。传递单个数组时一切正常,如下所示:
/?s=example&genres[]=term1&genres[]=term2
但是,当添加第二个不同分类的数组时,如...
/?s=example&genres[]=term1&genres[]=term2&keywords[]=term3&keywords[]=term4
...搜索结果页面上出现一些 PHP 错误
Warning: strpos() expects parameter 1 to be string, array given in /nas/wp/www/staging/pbsi/wp-includes/query.php on line 1861
Warning: preg_split() expects parameter 2 to be string, array given in /nas/wp/www/staging/pbsi/wp-includes/query.php on line 1862
Warning: Invalid argument supplied for foreach() in /nas/wp/www/staging/pbsi/wp-includes/query.php on line 1863
Warning: strpos() expects parameter 1 to be string, array given in /nas/wp/www/staging/pbsi/wp-includes/query.php on line 1861
Warning: preg_split() expects parameter 2 to be string, array given in /nas/wp/www/staging/pbsi/wp-includes/query.php on line 1862
Warning: Invalid argument supplied for foreach() in /nas/wp/www/staging/pbsi/wp-includes/query.php on line 1863
有没有更好的方法通过一个不会触发这些错误的查询字符串传递两个单独的数组?
【问题讨论】:
-
http_build_query()
标签: php arrays wordpress search query-string