I am trying to see if I can change an alt text of a featured image on only specific blog posts.
Whenever I upload an image, it allows me to add a default title, caption, alt text and description.
However, I sometimes need to use a different alt text for the same image. The problem is I am only able to use the default alt text I set upon uploading the image whenever I add a featured image.
I have created a custom field via advanced custom fields plugin. Custom field value can be accessed via using the code:
<?php the_field('myvalue'); ?>
Now, I am trying to see if I can come up with some code that allows me to add value from custom field and update the featured image
I am trying to see how i can edit the following code so that the alt attribute can be changed to whatever value in custom field "myvalue"
$title_attribute = the_title_attribute( array( 'echo' => FALSE ) );
the_post_thumbnail(
'full',
array(
'alt' => $title_attribute,
'title' => $title_attribute
)
);
'alt' => the_field('myvalue'),
?