Support » Plugin: WP REST API (WP API) » Get multiple posts/media by ID

  • Resolved eigilsagafos

    (@eigilsagafos)


    Hey,

    I’m wondering how I can get multiple media items at a time by their ID? I’m able to get one at a time, and have tried to figure out if there is a way to do it with filters, but no luck so far. When trying to fetch all the images for a post I now have to get them one by one by their ID.

    Any ideas?

    https://wordpress.org/plugins/json-rest-api/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Ryan McCue

    (@rmccue)

    You should be able to do it with the post__in filter:

    GET /posts?filter[post__in][]=1&filter[post__in][]=2&filter[post__in][]=3

    We’ve got a documentation ticket open for this too. 🙂

    Thanks!

    I can’t seem to get this to work. I’m trying:

    base/wp-json/posts?filter[post__in][]=499&filter[post__in][]=496

    It’s giving me posts with id of 499 and 496, but it’s also giving me every single other post on my site. Any ideas? I haven’t explicity enabled or used sticky posts, if that helps.

    I have the exact same problem. I have tested on a basic install with only 1 post with id 1 and this string /wp-json/posts?filter[post__in][]=2 still returns that post, which it shouldn’t AFAIK.

    Is this something that is fixed in the version not yet pushed to the wordpress repo?

    I am testing this issue.
    http://www.examsbook.com/wp-json/posts?filter%5Bpost__in%5D%5B%5D=4824

    This should return the post with id 4824
    But this is returning other posts. Seems this filter is not applied.
    Any helped in this ?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Get multiple posts/media by ID’ is closed to new replies.