My client has provided me with hundreds of images that have to be set as featured images for posts named after a part of the image’s title. Those images were uploaded to the Media Library already.
Is there a way to iterate through all of those files and process them with a function of my own? I need to extract the title of each image, create a post based on that image’s title and add two additional images to each post. I don’t want to do it manualy because it would take me ages to get it done.
This is a good start:
https://codex.wordpress.org/Template_Tags/get_posts
https://tommcfarlin.com/programmatically-create-a-post-in-wordpress/
Use get_posts to get all the attachments (post_type => ‘attachment’), then loop through the attachments and programmatically create your posts. Add in a separate function to upload two additional photos while you are creating the post.