WebDevStudios / Automatic-Featured-Images-from-Videos

If a YouTube or Vimeo video exists in the first few paragraphs of a post, automatically set the post's featured image to that vidoe's thumbnail.
33 stars 24 forks source link

Way to trigger setting of featured image, in mass, for existing posts. #7

Closed tw2113 closed 7 years ago

tw2113 commented 9 years ago

https://wordpress.org/support/topic/way-to-mass-update-existing-posts?replies=4

Caf commented 9 years ago

Since the only other plugin doing that is broken atm, that would be an AWESOME addition. ;)

tw2113 commented 8 years ago

After some quick testing, I found that a WP_Query as simple as this would do the trick:

$args = array(
    'post_type' => array( 'post' ),
    'posts_per_page' => -1,
    'cache_results'  => false,
    'update_post_meta_cache' => false,
);
$query = new WP_Query( $args ); var_dump($query);
foreach( $query->posts as $post ) {
    wds_set_media_as_featured_image( $post->ID, $post );
}
renatonascalves commented 8 years ago

'posts_per_page' => -1, will overload and crash the server, considering sites with thousands of posts.

tw2113 commented 8 years ago

Would be easy enough to amend and utilize the offset parameter.

tw2113 commented 7 years ago

Closing in favor of #27