我正在为我的 Wordpress 自定义查询问题寻找解决方案。
我有一个搜索表单,用户可以在其中输入一些文本,该文本可以是来自post_title
或meta_value (Company ID)
.
所以,我需要在post_title
或meta_key-Field
“id-number”中搜索字符串,但我还有一些其他额外的搜索参数。
这些是我的参数WP_Query
:
Array(
[post_type] => company
[pagination] => 1
[posts_per_page] => 10
[paged] => 1
[meta_query] => Array
(
[relation] => AND
[0] => Array
(
[0] => Array
(
[key] => id-number
[value] => FOOBAR
)
[1] => Array
(
[key] => post_title
[value] => FOOBAR
[compare] => LIKE
)
[relation] => OR
)
[1] => Array
(
[relation] => AND
[0] => Array
(
[0] => Array
(
[key] => country
[value] => USA
)
[relation] => OR
)
)
)
)
Array[meta_query][0][1] (post_title)
只是一个占位符 - 我知道这行不通,但我如何搜索
(id-number OR post_title)
AND(all other vars...)