S
S
Smeecy Smeecy2021-06-22 16:16:58
WordPress
Smeecy Smeecy, 2021-06-22 16:16:58

How to completely remove products from the site?

The code below removes products that do not have images from the catalog, but they are still uploaded to the site (they can be found through the search, the full number of products, including the removed ones, is displayed in the sidebar). How to make it so that the removed products are not displayed anywhere at all and are not taken into account?

add_action( 'woocommerce_product_query_meta_query', 'custom_product_query_meta_query', 1000 );
function custom_product_query_meta_query( $meta_query ) {
    if ( ! is_admin() ) {
        $meta_query[] = array(
            'key'     => '_thumbnail_id',
            'compare' => 'EXISTS',
        );
    }
    return $meta_query;
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question