0

I have just migrated a massive site (2500+ users, 5000+ posts/images) to Wordpress using custom code. Basically every post has one image and that image is attached to the post as the featured image, and all images show on the Media Library.

I have also managed to keep the original submission date for every post (which is the same date each image was uploaded) and to save every image under the corresponding /wp-content/uploads/[year]/[month] folder.

So far so good.

Hoever... all those image files and all entries on the Media Library, show the migration date (Nov 2011) instead of the original file creation/post creation date (variable from 2003 to 2009). This makes it very difficult to find which image belongs to a certain post, as image creation date information was lost.

So I need to update the dates of all Media Library entries and image file creation (same thing?), to the date of the post they are attached to.

Any idea what's the best way to go about it?

Any help would be truly appreciated.

1 Answer 1

1

Iterate over all posts, find the attached images

$images =& get_children( 
    array ( 
        'post_type'      => 'attachment', 
        'post_mime_type' => 'image' 
);

… and for each image use wp_update_post() to set the date from the parent post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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