Hi, thanks for the great plugin. I used it for CPT posts and it’s working fine, but i need to set featured image based on ACF field selection based condition. Can you please tell how can i set these condition based featured image.
Thanks, Jagan
The page I need help with: [log in to see the link]
That’s absolutely possible but you will have to custom code it. Depending your ACF fields. I understand you already found the code snippets for CPT.
add_filter( 'dfi_thumbnail_id', 'dfi_acf_rough_example', 10, 2 );
function dfi_acf_rough_example( $dfi_id, $post_id ) {
$post = get_post( $post_id );
$acf_field = get_field('ACF_FIELD', $post->ID);
if ( $acf_field === 'value to check' ) {
return 31; // the image id for the book post type.
}
return $dfi_id; // the original featured image id.
}
What value you get back does depend on the acf field type. Might be a string, might be an array.
Thanks for the reply, I added those custom codes with ACF field value but the default CPT image only displaying. Could you please check my codes in the images ?
Thanks, Jagan
This reply was modified 1 year, 6 months ago by ejaganece.