Getting alt text of featured image

Question

I’m trying to get the alt text of our featured image and have it output on the frontend.

Currently my code is

<img class="vehicle-photo" src="<?php echo the_post_thumbnail_url() ?>" alt="<?php the_post_thumbnail_caption();?>" />

But on the frontend, it is outputting as

<img class="vehicle-photo" src="photo url here" alt="">
0
Matt 4 weeks 0 Answers 5 views 0

Leave an answer