WordPress.org

Support

Support » Plugins and Hacks » How to set thumbnail for old posts to be the first image attached?

How to set thumbnail for old posts to be the first image attached?

  • And maybe not just the first post, it saves time to have this done my default. Any ideas?

    I don’t think going back to every post and choose a thumbnail is a solution, some blogs have thousands of posts.

Viewing 1 replies (of 1 total)
  • This may or may not be helpful… but a little while ago I wrote a function to handle thumbnails that first looked for something in a custom field and, failing that, reverted to the first attachment found with this function:

    wp_get_attachment_thumb_url($wpdb->get_var("SELECT ID FROM wp_posts WHERE post_parent = $post->ID AND post_type = 'attachment' AND post_mime_type LIKE 'image%' ORDER BY post_date ASC"))

    You’ll have to mess around with it and integrate it into a higher level function to have it work properly. There’s probably a much better solution but I know what it’s like to have a little issue like this and receive zero response on the support forums so at least it’s something…

Viewing 1 replies (of 1 total)
  • The topic ‘How to set thumbnail for old posts to be the first image attached?’ is closed to new replies.
Skip to toolbar