WooCommerce delete posts by taxonomy

Delete bulk products by taxonomy using the amazing WP_Query() function delete_products() { $args = array( ‘post_type’ => ‘product’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘$taxonomy-name’, ‘field’ => ‘slug’, ‘terms’ => “$taxonomy-value” )), ‘posts_per_page’ => 1000 // for some reason this is needed. ); $loop = new WP_Query($args); while ($loop->have_posts()) : $loop->the_post(); $product […]

Continue reading


Woocommerce REST API – Fetch Products by Category

Patching the class-wc-api-products.php in woocommerce/includes/api file. Replace the query_products($args) to private function query_products( $args ) { // set base query arguments $query_args = array( ‘fields’      => ‘ids’, ‘post_type’   => ‘product’, ‘product_cat’ => $args['product_cat'], ‘post_status’ => ‘publish’, ‘meta_query’  => array(), ); Use by the [filter] parameter in the API as filter[product_cat]=category-slug  

Continue reading