[HELP] U-Design Automatic Featured Image/Post Thumbnail

10zen

Power Member
Joined
Feb 26, 2010
Messages
777
Reaction score
368
U-Design needs featured images to be assigned manually.
I want to show first post image as post thumbnail in post excerpts.

I used some codes found online but it seems to not work properly, puts some "Edit" text
before excerpts in my localhost wp. Probably interferring with themes code.

Any help would be appreciated!
 
Anybody? Just need to activate/set first post image as post thumbnail.
I'm sure there are many wp users and coders here.

Would appreciate the help.
 
Anybody? Just need to activate/set first post image as post thumbnail.
I'm sure there are many wp users and coders here.

Would appreciate the help.

If I understand your question - you are trying to set the thumbnail and featured image with different pictures.....
you can specify the post image/thumbnail with the following customer field code; post_image. The value will be the link to the picture you want to use as thumbnail.
 
If I understand your question - you are trying to set the thumbnail and featured image with different pictures.....
you can specify the post image/thumbnail with the following customer field code; post_image. The value will be the link to the picture you want to use as thumbnail.

Thanks for trying to help but I know that already.

I don't want to keep adding featured image separately, instead want to assign first post image as
post thumbnail.

Used this code:
Code:
function auto_featured_image() {
    global $post;

    if (!has_post_thumbnail($post->ID)) {
        $attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
        
      if ($attached_image) {
              foreach ($attached_image as $attachment_id => $attachment) {
                   set_post_thumbnail($post->ID, $attachment_id);
              }
         }
    }
}
// Use it temporary to generate all featured images
add_action('the_post', 'auto_featured_image');
// Used for new posts
add_action('save_post', 'auto_featured_image');
add_action('draft_to_publish', 'auto_featured_image');
add_action('new_to_publish', 'auto_featured_image');
add_action('pending_to_publish', 'auto_featured_image');
add_action('future_to_publish', 'auto_featured_image');
But this exact code is already in themes's function.php but don't know how to
turn it on. But if I add this code it works but with mentioned glitch.
 
Back
Top