Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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