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 am looking for a way to generate featured image per post based on the first image in the post for old posts without a set featured image. I'm switching from handmade thumbnails to auto generated featured images. With new posts I got this working, but I don't want to set a featured image of my other 2000 posts by hand. Found some plugins, but they aren't working well or not supported and the info I did find here is all about setting the image with new posts. Any hook, script or function for this? Anyone got an idea?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You can look into this post: http://ken.ph/first-image-of-wordpress-post-as-thumbnail/

Or if you're comfortable with MySql try using this (obviously check it on local database first):

INSERT into wp_postmeta (meta_value, meta_key, post_id) 
SELECT DISTINCT(ID), post_type , post_parent 
FROM wp_posts 
WHERE post_type= 'attachment' 
AND post_parent !=0 
AND post_status='inherit';
UPDATE wp_postmeta set meta_key = '_thumbnail_id' 
WHERE meta_key='attachment'
share|improve this answer
    
Thanks! This will get me going! –  AKNL Oct 18 '12 at 8:58

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.