0

我们有这样的功能:

must_be_hide($post_id) {
  $bool = in_array($post_id, array(1, 2, 3, 4 ,5));
  return $bool;
}

如何使用此功能从 woocomerce 目录(商店)和搜索结果中隐藏产品?

4

1 回答 1

0

您必须更改搜索循环并使用以下代码:

$_pf = new WC_Product_Factory();
$_product = $_pf->get_product($id); // assuming $id is available as the code is inside the loop
$_product->is_visible()
于 2017-03-12T22:26:12.717 回答