WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Ionut
    Member
    Posted 4 years ago #

    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.

  2. Xerotone
    Member
    Posted 4 years ago #

    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...

Topic Closed

This topic has been closed to new replies.

About this Topic