ACF子字段和WordPress组合搜索

时间:2019-07-05 19:07:33

标签: php database wordpress advanced-custom-fields

我想实时搜索其中包含元查询的帖子。 中继器字段中有中继器,例如

  • 帖子类型:帖子
  • 一级转发器:一级
  • 第1级子字段中继器(第2级):第2级
  • 第2级中继器子字段:说明,标题

我希望查询通过匹配提供的搜索文本(例如“ co”)来显示帖子,该搜索文本搜索帖子标题,子字段描述和子字段标题并返回匹配的帖子。 有什么办法可以做到这一点? 以下是我的查询节目。


$post_meta_args = array();
if ( is_array( $myValues ) || is_object( $myValues ) ) {
foreach ( $myValues as $value ) {
array_push( $post_meta_args, array(
'key'     => 'description',
'value'   => 'mar',
'compare' => 'LIKE'
) );
}
}
$args = array(
'post_type'      => 'post',
'posts_per_page' => - 1,
's'              => 'co',
'meta_query'     => $post_meta_args
);


$the_query = new WP_Query( $args );

0 个答案:

没有答案