0
votes
1answer
364 views

Using set_post_thumbnail inside save_post action gets overwritten

I've added my own function to save_post as follows: add_action( 'save_post', 'save_recipe' ); function save_recipe( $post_id ) { // ... set $thumb_id from custom code ... ...
3
votes
2answers
3k views

Retrieve 1st image in post and set it as featured image, when post is saved/updated

I need to set a featured image for every post I publish. So, when a post is published/updated, the script would scan the post for the first image using a script like this: // Get URL of first ...