Automatically Thumbnail Old and Current Posts via Custom Field? (3 posts)

  1. hellove
    Posted 3 years ago #


    I have been using a theme that didn't support thumbnails on the home pages for over three years. I now have a massive amount of content without thumbnail posts.

    I want to switch to a theme that does support thumbnails. Is there a way to automatically generate thumbnails for all of my wordpress posts based on the first image in any given post to accomplish this? I really like some of the modern looks of these types of themes but it would be impossible to go back and custom field thumbnails one-by-one.

    If anyone knows of a solution for this, I would really appreciate it?

    Thank you!

  2. hellove
    Posted 3 years ago #

    bump, anyone?

  3. esmi
    Forum Moderator
    Posted 3 years ago #


    $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );
    $attachments = get_posts($args);
    if ($attachments) {
    	$thumb = $attachments[0];
    	echo wp_get_attachment_image( $thumb->ID, 'thumbnail' );


Topic Closed

This topic has been closed to new replies.

About this Topic