WordPress.org

Forums

WP REST API (WP API)
[resolved] Get multiple posts/media by ID (6 posts)

  1. eigilsagafos
    Member
    Posted 1 year ago #

    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/

  2. Ryan McCue
    Member
    Plugin Author

    Posted 1 year ago #

    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. :)

  3. eigilsagafos
    Member
    Posted 1 year ago #

    Thanks!

  4. mistermchem
    Member
    Posted 5 months ago #

    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.

  5. kokarn
    Member
    Posted 2 months ago #

    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?

  6. morwalz
    Member
    Posted 1 week ago #

    I am testing this issue.
    http://www.examsbook.com/wp-json/posts?filterpost__in=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 ?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP REST API (WP API)
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic