I’m creating post in wordpress via external api from my php api. I’ve been able to create post and set feature image for it, but I need to know on how to update following information :
- image alt text
- image caption
- image title
this question might sound stupid, but I didn’t find strong sample for the solution.
You can try this one:
if you image file has the meta data, you can use the following function to generate the data automatically.
Find more about the variables the above function generates in the following link
https://codex.wordpress.org/Function_Reference/wp_generate_attachment_metadata
If the file does not have meta, You have form as an array manually like the following one.
You can get an idea about an image’s metadata variables in the following link.
https://codex.wordpress.org/Function_Reference/wp_read_image_metadata#Return_Values
Finally update the values as metadata to that attachment.