WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. eigilsagafos
    Member
    Posted 10 months 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 10 months 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 10 months ago #

    Thanks!

  4. mistermchem
    Member
    Posted 3 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 4 weeks 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?

Reply

You must log in to post.

About this Plugin

About this Topic