Setting All Drafts to ‘exclude-from-catalog’ in WooCommerce
Look into wp_set_object_terms() You could do something along the lines of: wp_set_object_terms( $post_id, ‘exclude-from-catalog’, ‘product_visibility’ ); Getting all posts by status, use Wp_Query. I added the ‘fields’ => ‘ids’ param to limit the query to only ids, rather than gathering whole post objects. On an array of posts that have Draft or Pending as a … Read more