0

We are creating a new website and want to pull all featured images into the new site, but we don't want all the images from the WP database, only the featured blog post images. Is there a plugin or some other way to do this? We are hoping we won't have to pull the entire wp-uploads folder to the new site.

Thanks in advance!

  • Do you just want the files? Or you need to get the files and automatically do something with them? – mozboz Jul 13 at 9:46
0

Sorry this isn't a full answer, but yes this probably is possible but you need to run a database query or some code to find the images, and then do something with that list such as copy the files to a new directory.

There's info here on how featured images are stored.

Here's a quick suggestion based on that post, written as pseudocode, but if it's what you want and you know how to write a bit of Wordpress PHP this should be quite easy and potentially save a ton of time if you were going to do this manually.

    foreach ($allPostIDs as $postId) {  // get all post ID's somehow and loop through them
        if(has_post_thumbnail($postId)) {  // if post has featured image
            $fileInfo = get_attached_file(get_post_thumbnail_id($some_post_id));        
            // do something with the file info, like copy all files to a new directory or output to screen
        }
| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.