WordPress.org

Ready to get started?Download WordPress

Forums

JSON REST API (WP API)
Passing filters (7 posts)

  1. darinreid
    Member
    Posted 1 year ago #

    I can do this:

    Get all posts (defaults to 'post' type): /wp-json.php/posts/
    Get defined post types: /wp-json.php/posts/types/
    Get single post by id (e.g. '11'): /wp-json.php/posts/11

    I can see that the getPosts method accepts a $filters argument. How would I pass filters to the posts endpoint?

    Thanks for any information and for contributing this plugin!

    Darin

    http://wordpress.org/extend/plugins/json-rest-api/

  2. Ryan McCue
    Member
    Plugin Author

    Posted 1 year ago #

    Apologies for not getting back to you sooner!

    $filters can be passed in as GET parameters: ?filters[x]=y

  3. web559
    Member
    Posted 10 months ago #

    Thanks. I didn't find this on the docs.

  4. ajberasategui
    Member
    Posted 10 months ago #

    I case someone else have problems with it, filters should be passed as
    ?filter[x]=y
    filter instead of filterS.

    Thanks for this awesome plugin!

  5. Patrick Hesselberg
    Member
    Posted 9 months ago #

    Also, remember to pass filter[x]=y when you want to filter multiple things:

    ?filter[post_status]=draft&filter[posts_per_page]=2

    Took me some time to figure out...

  6. Geet Jacobs
    Member
    Posted 9 months ago #

    EDIT: removing my post info and made a new one, apologies for adding what I thought was a related question but not directly the same.

    "Hopefully jumping on this thread was ok since it also related to filters.

    Cheers!"

  7. esmi
    Forum Moderator
    Posted 9 months ago #

    @Geet Jacobs: It is considered impolite to interrupt another poster's ongoing thread unless you are posting a solution or suggestion. It causes significant problems for the forum's volunteers and prevents us from being able to track issues by topic. Please post your own topic.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.