使用 'LIKE %word%' 进行 ACF 查询 Wordpress

Use 'LIKE %word%' for ACF Query Wordpress

我在我的 wordpress 网站上使用 ACF 插件,我想编写自定义研究代码。 我有很多产品,我想显示包含搜索词的产品。

我这样查询:

$args = array(
            'post_type' => 'product',
            'meta_key'      => 'brand',
            'meta_value'        => $word,
            'compare'   => 'LIKE');



$the_query = new WP_Query($args);

但这里只显示与 $word 完全匹配的品牌的产品。 例如,如果我搜索 "yan" 我想展示品牌为 "YANMAR"、"POLYAN"、"TRYANPO" 等的产品

请问如何操作?

谢谢你,祝你有美好的一天!

试试下面的代码。

$args = array(
    'post_type' => 'product',
    'post_status' => 'publish',
    'posts_per_page' => -1,
    'meta_query' => array(
      array(
        'key' => 'brand',
        'value' => $word,
        'compare' => 'LIKE'
      )
    )
);
$the_query = new WP_Query($args);