Error adding as thumbnail the first image from the gallery
-
This code below (I used the code that was shared on github https://github.com/Crocoblock/suggestions/issues/3985) was working perfectly in my form, but I updated from the latest version (2.1.6) and now is no longer adding the image as a thumbnail of the post. Does it have any solution?
add_action( 'save_post', function ( $post_id ) { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } $gallery_key = 'property_photos'; $gallery = get_post_meta( $post_id, $gallery_key, true ); if ( empty( $gallery ) ) { return; } $gallery = explode( ',', $gallery ); $image_id = $gallery[0]; set_post_thumbnail( $post_id, $image_id ); }, 99 );
- The topic ‘Error adding as thumbnail the first image from the gallery’ is closed to new replies.