Search SKU and Product Title

Amend your search query with the following.

$query_withMeta_search = new WP_Query(
    array(
        "post_type" => "product",
        "s" => $search_query,
        "meta_query" => array(
                "key" => "_sku",
                "value" => $search_query,
                "compare" => "LIKE"
        )
    )
);

Leave a Reply

Your email address will not be published. Required fields are marked *