I'm trying to display images with their caption, but when I do it displays both the caption and that alt text. I've tried to use unset( $fields['image_alt'] );
to hide the alt text, but it does nothing. Here's my code:
<?php if (the_post_thumbnail_caption()) {
the_post_thumbnail_caption();
}
function remove_alt( $fields ) {
unset( $fields['image_alt'] );
return $fields;
}
add_filter( 'attachment_fields_to_edit', 'remove_alt', 999, 1 );
?>
It first gets the caption, if there is one, and then the function is supposed to remove the alt text and keep the caption, but it's not working. Any suggestions for how to get this to work? Thanks so much for the help :)