WordPress.org

Ready to get started?Download WordPress

Forums

User Submitted Posts
[resolved] Set image to featured image? (4 posts)

  1. clinton4
    Member
    Posted 1 year ago #

    Hi,

    would it be possible to automatically set the first image to be the featured image for the post?

    http://wordpress.org/extend/plugins/user-submitted-posts/

  2. Jeff Starr
    Member
    Plugin Author

    Posted 1 year ago #

    Not currently, but it's on the list for the next update.

  3. Jeff Starr
    Member
    Plugin Author

    Posted 1 year ago #

    Responding to mark this as resolved.

  4. bakivaki
    Member
    Posted 9 months ago #

    function autoset_featured() {
              global $post;
              $already_has_thumb = has_post_thumbnail($post->ID);
                  if (!$already_has_thumb)  {
                  $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);
                                    }
                               }
                            }
          }
    add_action('the_post', 'autoset_featured');
    add_action('save_post', 'autoset_featured');
    add_action('draft_to_publish', 'autoset_featured');
    add_action('new_to_publish', 'autoset_featured');
    add_action('pending_to_publish', 'autoset_featured');
    add_action('future_to_publish', 'autoset_featured');

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.