Last active
August 1, 2022 00:53
-
-
Save zarankumar/f80a73598152edf7d67a8c91dbf3be25 to your computer and use it in GitHub Desktop.
Add image to product gallery programmatically - woocommerce .Woocommerce manage field ‘_product_image_gallery’ with id of images separatly for comma.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Add image to product gallery programmatically - woocommerce | |
Woocommerce manage field ‘_product_image_gallery’ with id of images separatly for comma. | |
*/ | |
$list_id = "444,555"; | |
update_post_meta($post_id,'_product_image_gallery',$list_id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works for me:
$media = get_attached_media('image', $pid);
update_post_meta($pid, '_product_image_gallery', implode(',', array_keys($media)));