I have a function that is being called whenever a woocommerce product is published (through the save_post hook).

This function uploads a few images, attaches them to the current post being saved (using update_post_meta with the _product_image_gallery key and set_post_thumbnail function).

If I create and publish a product through the wp admin dashboard, this works great, no issues.

If I create a product through the REST API, the images get uploaded (so my function on the save_post hook is being called), but the image ID's do not get saved in the database.

The update_post_meta function on the rest API call does return a meta ID, however searching in the wp_postmeta table, this ID is not to be found..

I feel like the REST API is somehow overwriting/deleting my update_post_meta call, and am curious if anyone else has ever ran into the same issue or has any workaround for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.