所以你的问题是meta_query
并传递tax_query
. 如果要搜索meta value
:
$params = array(
\'posts_per_page\' => -1,
\'post_type\' => \'product\',
\'orderby\' => \'menu-order\',
\'order\' => \'asc\',
\'fields\' => \'ids\',
\'meta_query\' =>
array(
array(
\'key\' => \'product_visibility\',
\'value\' => \'exclude-from-catalog\',
\'compare\' => \'!=\')
));
$wc_query = new WP_Query($params);
$ids = $wc_query->posts;
echo \'<pre>\';
print_r($ids);
echo \'</pre>\';
或者这个,如果是
term
$params = array(
\'posts_per_page\' => -1,
\'post_type\' => \'product\',
\'orderby\' => \'menu-order\',
\'order\' => \'asc\',
\'fields\' => \'ids\',
\'tax_query\' =>
array(
array(
\'taxonomy\' => \'product_visibility\',
\'field\' => \'slug\'
\'terms\' => \'exclude-from-catalog\',
\'compare\' => \'NOT IN\')
));
$wc_query = new WP_Query($params);
$ids = $wc_query->posts;
echo \'<pre>\';
print_r($ids);
echo \'</pre>\';
查看更多关于
tax_query 和
meta_query.