I want to modify a WooCommerce plugin in order to pick products of a selected tag of the name "right-tag" for example.
My Code is of the form:
$query =$wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "posts WHERE `post_type` LIKE 'product' AND `post_status` LIKE 'publish'",0);
/* do something */
foreach ($result as $index => $prod) {
$sql = $wpdb->prepare( "SELECT *
FROM " . $wpdb->prefix . "postmeta
WHERE `post_id` =" . $prod->ID . " AND `meta_key` LIKE '_stock_status';",0);
/* do something */
/* do something */
Can you help me?
Thanks a lot Giannis
MySQL query to get product by specific tag:
Equivalent WordPress/PHP query
Both MySQL query & Code is tested and works.
Hope this helps!