我想搜索custom_post
按标题和ACF字段。
所以,我用了WP_Query
WordPress函数,但我不能按标题过滤,只能按过滤器过滤。
当我提交表单时,我有这样的URL:
http://example.com/?s=titre&filter1=condition1&filter2=condition2&filter3=condition3
我的代码:$title = $_GET[\'s\'];
$args = array(
\'pagename\' => $title,
\'numberposts\' => -1,
\'post_type\' => \'my_custom_post\',
\'meta_query\' => array(
array(
\'key\' => \'filter_1\',
\'value\' => $_GET[\'condition_1\']
),
array(
\'key\' => \'filter_2\',
\'value\' => $_GET[\'condition_2\']
),
array(
\'key\' => \'filter_3\',
\'value\' => $_GET[\'condition_3\']
)
)
);
$the_query = new WP_Query($args);
你有没有办法在搜索中包含标题?