I have a handful of products in my WooCommerce Store set to Catalog & Search
and a bunch more just set to a visibility of just Search
.
I put a lot of work into making sure my Catalog was nice and clean, but now I need to do some additional work on them and am trying to retrieve the IDs of products that are ONLY in my Catalog and not just search.
I've tried a few things, but something is amiss somewhere.
What am I missing?
$params = array(
'posts_per_page' => -1,
'post_type' => 'product',
'orderby' => 'menu-order',
'order' => 'asc',
'fields' => 'ids',
'meta_query' =>
array(
array(
'taxonomy' => 'product_visibility',
'value' => 'exclude-from-catalog',
'compare' => '!=')
));
$wc_query = new WP_Query($params);
$ids = $wc_query->posts;
echo '<pre>';
print_r($ids);
echo '</pre>';
With this Query it's still returning all Product IDs.
I'm assuming there must be something wrong with my meta_query
argument. What I was going for was to look for the product_visibility
taxonomy
and exclude (!=
) those that have the value exclude-from-catalog
.
Anyone know where I'm going wrong with this?