0

I want to exclude the product content from woocommerce search. I tried the following code in my theme functions.php but it not works:

if( ! is_admin() ) {
    function wpb_search_filter( $query ) {
        if( $query->is_search ) {
            $query->set( 'post_content', 'post' );
        }
        return $query;
    }
    add_filter( 'pre_get_posts','wpb_search_filter' );
}

Can somebody help me ?

I want my products to be searchable for title and SKU only. For search by SKU I have a solution that works, but I don't know how to exclude the content from the search.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.