WordPress   

Hide Woocommerce simple products from search results

//hide simple products from search
add_action('pre_get_posts', 'hide_simple_products_from_search');
function hide_simple_products_from_search($query) {
    if ($query->is_search() && $query->is_main_query()) {
        $tax_query = $query->get('tax_query', array());
        $tax_query[] = array(
            'taxonomy' => 'product_type',
            'field'    => 'name',
            'terms'    => 'simple',
            'operator' => 'NOT IN',
        );
        $query->set('tax_query', $tax_query);
    }
}
Need Professional Support for Your Website Problems?

Whether you're facing website issues or struggling with code implementation, our team is here to assist. Hire us to get your website back on track.

Hire Us

Got an idea? We'll turn it into reality.

Tell us what you're building, what's broken, or what numbers need to move. We'll come back within one business day with a short plan — no long decks, no sales calls without purpose.

Response time: First reply within 1 business day on 100% of messages.
Transparent scope: Fixed proposals with weekly check-ins & live task tracking.
Ship-ready builds: Every engagement leaves behind documented, transferable work.
Long-term partners: Ongoing retainers for support, SEO, ads, and content.