Skip to content
Advertisement

Get WordPress Featured Image “alt”

I’m trying to get a page’s featured image alt and echo it as paragraph text but my code doesn’t seem to be working.

I’m currently able to echo the image and it’s working perfectly.

Here’s the code I’m using:

JavaScript

Advertisement

Answer

Here’s a solution:

JavaScript

Or you can use your code, but instead of echoing $alt directly you need to echo $alt->post_excerpt.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement