查找具有完全相同名称的其他产品

Find other product with exact same title

以下代码获取我需要的产品,但它与确切的图块(名称)不匹配,所以有时它会得到一些不需要的产品。

$pname = $product->get_name();

$args = array(
 'post_type' => 'product',
 'post_status' => 'publish',
 'posts_per_page' => '5',
 'order' => 'asc',
 "s" => $pname,

 'tax_query' => array(
   array(
    'taxonomy' => 'product_type',
    'field' => 'slug',
    'terms' => 'bundle',) )
);

$products = new WP_Query($args);

现在如果我添加 'meta_qury',它根本不起作用,页面显示错误。

$args = array(
 'post_type' => 'product',
 'post_status' => 'publish',
 'posts_per_page' => '5',
 'order' => 'asc',
 "s" => $pname,

  'tax_query' => array(
   array(
    'taxonomy' => 'product_type',
    'field' => 'slug',
    'terms' => 'bundle',) )

  'meta_query' => array(
   array(
    'key' => 'title',
    'value' => $pname,
    'compare' => '=') )
);

有人可以帮我解决这个问题吗?我是 WordPress 新手 PHP.

很简单,改一下就可以了

"s" => $pname,

'title' => $pname,

在原始代码中未添加任何内容 'meta_query' 解决了问题。