Using custom field to change alt text for a featured image
I think you gave the answer in your last comment. if (get_field(‘alt_image_f’)){ $post_thumbnail_attr = array(‘alt’ => get_field(‘alt_image_f’) ); the_post_thumbnail( ‘full’, $post_thumbnail_attr ); } else the_post_thumbnail(); Cleaning up your code a bit, the following should work $custom_image_alt = get_field(‘alt_image_f’); $post_thumbnail_attr = array(); if ($custom_image_alt) { $post_thumbnail_attr[‘alt’] = $custom_image_alt; } the_post_thumbnail(‘full’, $post_thumbnail_attr);