WordPress.org

Ready to get started?Download WordPress

Forums

JSON REST API (WP API)
[resolved] Filter parameter (3 posts)

  1. thonyfd
    Member
    Posted 6 months ago #

    [Moderator note: Topic title de-capped. Please do not shout at us.]

    Hi all, i have a few days trying to use the filter parameter, but i don't have idea how to send the filter information.

    Do you have an example or most detailed documentation for this functionality?

    Your plugin is great! but i have short rest experience.

    Best regards!

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

  2. thonyfd
    Member
    Posted 6 months ago #

    Hi Guys,sorry for the title.

    About my problem i added this lines in "class-wp-json-posts.php"

    if(isset($filter) && $filter !==''){
    $filter = json_decode(stripslashes($filter),true);
    }

    and i'm using an angularjs ajax method like this

    var filter = {};
    filter['posts_per_page'] = 5;
    filter['post_type'] = 'Post';
    filter['cat'] = 5;

    $http.get('http://myhost/wp-json.php/posts', {params: {"filter": JSON.stringify(filter)}}).success(function(data) {
    //something here
    });

    this it solve my problem but, is there a better way to use the filter parameter ?

    thank's for all, and sorry again .

  3. thonyfd
    Member
    Posted 6 months ago #

    I find my answer in this post jeje

    http://wordpress.org/support/topic/passing-filters?replies=7

    Best Regards!

Reply

You must log in to post.

About this Plugin

About this Topic