the gallery is a post type as you might have guessed already.
Can you please check if the gallery exists on the site in context? Also, the media from a specific site ca be added to gallery on that site(gallery is set as parent post of the media internally in MediaPress).
Please let me know if these conditions have met? If yes, please share your complete code using pastebin to allow me try the same.
I tried it and found above variable in $media_data looking to have POST File type data with => enctype=”multipart/form-data” headers.
We can’t pass the values in that way as media already there on the server.
I thought passing all static values(for testing) in $media_data may get some lead. We tried to assign all valid values to $media_data but not succeed.
Please help us to fix this issue we just 1 step behind to conclude the requirement that is attach the media with gallery.
Since you are able to successfully create an attachment, why not import it to gallery using
mpp_import_attachment( $attachment_id, $gallery_id, $override = array() );
This function calls import attachment internally whose implementation you can see here.
This should be straight forward solution for you.
Here is even easier suggestion.
1. Use WordPress api to add file as an attachment
2. Use the attachment id and import it to your gallery using the above solution
You do not need to worry about upload locations etc as the plugin will take care of that.
Thanks, I think the same API concept already using in our custom script no separate function is being used in the program.
Furthermore will try it with the POSTMAN tool to check attachment is working or not and will get back to you.
Would you please send me the media press endpoints to attach the media with Gallery?
You must be logged in to reply to this topic.