Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add image to product gallery programmatically - woocommerce .Woocommerce manage field ‘_product_image_gallery’ with id of images separatly for comma.
@m-torin
Copy link

m-torin commented Aug 8, 2018

Works for me:
$media = get_attached_media('image', $pid);
update_post_meta($pid, '_product_image_gallery', implode(',', array_keys($media)));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment