I have those products:
Name1 SECONDNAME 1
Name1 SECONDNAME 2
Name1 SECONDNAME something
Name1 SECONDNAME something 5
Name2 SECONDNAME 1
Name2 SECONDNAME 2
Name2 SECONDNAME something
Name2 SECONDNAME something 5
I want to list them like this:
$query = new WC_Product_Query( array(
'title' => 'Name1 SECONDNAME *'
) );
$products = $query->get_products();
2
Answers
Rather than
WC_Product_Query
, you could useWP_Query
and thesentence
parameter (tested):Here is a function that you can call where you need it. Add it in your functions.php file
Usage: