I want to insert into table shp_postmeta
when it does not have the meta_key = '_thumbnail_id'
.
The inserted value is from the same table shp_postmeta
where meta_key = '_product_image_gallery'
i.e. in form of sql statement
SELECT meta_key, meta_value FROM shp_postmeta WHERE meta_key = '_product_image_gallery'
This table is related to a different table shp_post
where shp_posts.ID = shp_postmeta.post_id
The table structure of shp_postmeta
is:
meta_id | post_id | meta_key | meta_value
Table structure of shp_posts
table is:
ID | post_author | ....
These are WordPress table structure.
EDIT 1
In WP there are some woocommerce product which does not have featured image but they have product gallery images. Images are uploaded into the media.So I wanted to make the gallery image to featured image to which products those do not have featured image. Products are in large amount. So I wanted to automate it through script.