Search code examples
wordpresswordpress-rest-api

Can't get featured image with WordPress REST API


I'm using WordPress REST API and can receive data from https://websitename.com/wp-json/wp/v2/posts?_fields=author,id,excerpt,title,link,featured_media_src_url.

The problem is featured_media_src_url is added with This WordPress Plugin and I can't retrieve it using URL filters. (it works by fetching just .../w/v2/posts without params)


Solution

  • It looks like the plugin gets the path using featured_media which returns an id. Adding this to the fields solves the problem: https://websitename.com/wp-json/wp/v2/posts?_fields=author,id,excerpt,title,link,featured_media_src_url,featured_media