0

I am trying to get the featured image of a post using the WordPress REST API. I am adding the extention of ?embed to the end if the REST API url and I am seeing the featured image data under ['wp:featuredmedia'], but I can't seem to display that data.

I am using Vue to display data from the REST API and so what I am doing currently to try and get the featured image source is: post._embedded['wp:featuredmedia'][0].source_url

But by doing that it can't find the source url of the featured image and I am not sure what is wrong with my path for it to not find the source url data?

  • It sounds like you're on the right path. However, without a specific code snippet to look at what you're doing, it's hard to say what the problem is. You could improve this question and get better answers if you post what you're using now to get the image and (attempt to) display it. – butlerblog Nov 30 '18 at 20:08
  • @butlerblog with Vue I am using {{ post._embedded['wp:featuredmedia'][0].source_url }} inside a div tag, with the normal Wordpress REST API – user9664977 Nov 30 '18 at 20:14
0

I used Better REST API Featured Image plugin. that adds the featured image URL to the original API response.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.