field selector (6 posts)

  1. aleclofabbro
    Posted 2 years ago #

    is it possible to retrieve just a set of fields in response?

    status: "ok",
    count: 2,
    count_total: 2,
    pages: 1,
    posts: [
    id: 14,
    title: "post3"
    id: 8,
    title: "posr2"
    query: {
    ignore_sticky_posts: true


  2. Bob Gregor
    Posted 2 years ago #

    Yes! Change fields to "include" in your example:


    Just an FYI - ID is always returned

    For more detail see http://wordpress.org/plugins/json-api/other_notes/#3.3.-Using-include/exclude-and-redirects

    To see which fields you can include/exclude, look @ the relevant model / response objects: http://wordpress.org/plugins/json-api/other_notes/#4.-Response-objects

  3. aleclofabbro
    Posted 2 years ago #

    Thank you!
    sorry i should have read it myself!
    another thing:
    what about the feature of a conditional query on custom_fields ..
    like "custom_fields.size > 10"
    if there's not this feature could you help me pointing me out where to focus for this extension ?
    Thank you very much!

  4. Bob Gregor
    Posted 2 years ago #

    See http://wordpress.org/plugins/json-api/other_notes/#3.2.-Content-modifying-arguments

    You'll be looking for the last line in that section: meta_key, meta_value & meta_compare. The keys are not defined there, however, so...

    JSON API uses the same parameters as WP_Query, if the JSON API docs are fuzzy or do not provide a context - the codex will help. I found the reference for your example here: http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters

    So, in your case, you're going to specify meta_key = "size", meta_value = 10, meta_compare = '>'

    meta_compare (string) - Operator to test the 'meta_value'. Possible values are '!=', '>', '>=', '<', or '<='. Default value is '='.

  5. aleclofabbro
    Posted 2 years ago #

    I'm testing it now.
    yes, i'm making it work!
    but is it also possible to format the url query to handle multiple queries as specified in http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters as new WP_Query( array (.<arrays_of_queries>.)) ?

  6. Bob Gregor
    Posted 2 years ago #

    Off the top of my head - I'm going to say no - I think multiple custom field queries are beyond the scope of the plugin. I'd ask Dan to chime in here for more info - he's the expert. If it doesn't support it, I'd suggest extending it if you want to perform complex queries like that.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic