Several customers of our Total theme have asked how they can display their secondary image on the single posts instead of the default featured image. So here is a little snippet for those wondering:
function myprefix_blog_entry_thumbnail_args( $args ) {
// Your secondary image ID
$secondary_image_id = 'secondary-image'; // NOTE: tweak this to match your ID
$secondary_image_meta_key = get_post_type() .'_'. $secondary_image_id .'_thumbnail_id';
// Get your second image and if it exists update the attachment param
// Note: Only if attachments is currently empty to prevent issues with sliders
if ( empty( $args['attachment'] )
&& $secondary_image = get_post_meta( get_the_ID(), $secondary_image_meta_key, true )
) {
$args['attachment'] = $secondary_image;
}
// Return args
return $args;
}
add_filter( 'wpex_blog_entry_thumbnail_args', 'myprefix_blog_entry_thumbnail_args' );
Several customers of our Total theme have asked how they can display their secondary image on the single posts instead of the default featured image. So here is a little snippet for those wondering:
ps: Great plugin guys!