Hi Vivek,
Use following function to set featured image for post. This function will set featured image for single post. Use this function for all posts you want to set featured image.
/**
* Re-save post images to set featured image.
*/
function gd_snippet_resave_post_images( $post_id ) {
$featured_image = geodir_get_post_meta( $post_id, 'featured_image', true );
if ( ! empty( $featured_image ) ) {
return true; // Don't generate featured image.
}
$post_images = GeoDir_Media::get_field_edit_string( $post_id, 'post_images' );
if ( ! empty( $post_images ) ) {
$post_images = $post_images . ' '; // Force re-save.
$featured_image = GeoDir_Post_Data::save_files( $post_id, $post_images, 'post_images', false, false );
if ( ! empty( $featured_image ) ) {
geodir_save_post_meta( $post_id, 'featured_image', $featured_image );
}
}
}
Regards,
Kiran