so I am trying to use WP-API plugin:
i figured out how to get all posts for custom post type:
http://domain/wp-json/posts?type[]=customType
and i figured out how to get attachments:
http://domain/wp-json/media/
Now the problem is how to get images attached to single post. if I look at the soruce it seems to suggest a path like:
http://domain/wp-json/media/<postId>/
but I get an error:
[{"code":"json_post_invalid_type","message":"Invalid post type"}]
any Idea how to get this to work?
You can use the “parent” id argument, e.g:
where is the post’s ID. What we do is ignore all versions of images except the original, which is found by looking for the GUID > rendered value, e.g:
As of this moment this functionality does not seem to be supported probably will be when the plugin goes into core but for now it is as is.
I ended up making my own json API to serve my needs by making the page templates recive emit JSON data.
Just an update to this old post. WP-API now supports getting media related to a particular post.
http://v2.wp-api.org/reference/media/
Code: