I want to display woocommerce product image from wordpress mysql database. for example, if a product has id 11 and its image, attribute, price etc are stored in wp-postmeta table in the database. The image is stored in someother id and the id value is given in image of the product 10. Now how to fetch image from the table.
for single product,
$img = mysql_query("SELECT meta_value FROM wp_postmeta WHERE meta_key ='_thumbnail_id' AND post_id='11'",$con);
$res= mysql_fetch_array($img);
$img2 = mysql_query("SELECT meta_value FROM wp_postmeta WHERE meta_key ='_wp_attached_file' AND post_id='".$res['meta_value']."'",$con);
$res2= mysql_fetch_array($img2);
echo $res2['metavalue'];
displays the image of single product, but how to fetch data from mysql database for multiple products?
I made something like this for getting images for all woocommerce products
// to get the multiple images of one product , post_paent value should be the produt id
use this plugin https://wordpress.org/plugins/get-the-image/
this will surly help you.