Title: Request by a specific custom fields
Last modified: August 30, 2016

---

# Request by a specific custom fields

 *  Resolved [rjme](https://wordpress.org/support/users/rjme/)
 * (@rjme)
 * [11 years ago](https://wordpress.org/support/topic/request-by-a-specific-custom-fields/)
 * I have a custom field (“special_field”) that either equals “1” or “0”. On all
   my other stuff I am using ?json=1&count=5 but I want to only get 5 posts that
   have “special_field” = “1”. What is the next thing that I should put on there?
   I can’t seem to find the answer myself.
 * [https://wordpress.org/plugins/json-api/](https://wordpress.org/plugins/json-api/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [lucasabba](https://wordpress.org/support/users/lucasabba/)
 * (@lucasabba)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/request-by-a-specific-custom-fields/#post-6223507)
 * I’ve the same problem, someone can help us?
 *  [Goldenapps](https://wordpress.org/support/users/goldenapps/)
 * (@goldenapps)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/request-by-a-specific-custom-fields/#post-6223556)
 * plz visit this page:
 * [https://wordpress.org/support/topic/plugin-json-api-add-meta-query-to-get_post?replies=2](https://wordpress.org/support/topic/plugin-json-api-add-meta-query-to-get_post?replies=2)
 *  [cristophergv](https://wordpress.org/support/users/cristophergv/)
 * (@cristophergv)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/request-by-a-specific-custom-fields/#post-6223569)
 * Hello rjme,
 * It is easy, when solicited query the system uses the parameters **meta_key** &**
   meta_value** as filters, namely:
 * If you created the custom field called special_field and its possible values ​​
   1 or 0 your query should look something like:
 * [http://www.mywebsite.com/?json=get_posts&post_type=post&amp](http://www.mywebsite.com/?json=get_posts&post_type=post&amp);**
   meta_key**=special_field&**meta_value**=1 or = 0
 * according to whether you want to filter for **1 or 0.**
 * If you have other custom field called my_special_field with possible values ​​
   yes or not your query would look like:
 * [http://www.mywebsite.com/?json=get_posts&post_type=post&amp](http://www.mywebsite.com/?json=get_posts&post_type=post&amp);**
   meta_key**=my_special_field&**meta_value**=yes
 * or
 * [http://www.mywebsite.com/?json=get_posts&post_type=post&amp](http://www.mywebsite.com/?json=get_posts&post_type=post&amp);**
   meta_key**=my_special_field&**meta_value**=no
 * Is everything, with that return values ​​can filter based on custom field.
 * Remember that you can use other parameters at WP_Query and seeing that functionality
   provides you.
 * [https://codex.wordpress.org/Class_Reference/WP_Query](https://codex.wordpress.org/Class_Reference/WP_Query)
 * Incidentally, the parameter post_type = post is optional, but it can be used 
   in cases where for example you create a type of personalized post such artists,
   books, since that way you can get only results of such post as:
 * [http://www.mywebsite.com/?json=get_posts&post_type=](http://www.mywebsite.com/?json=get_posts&post_type=)**
   artista**&meta_key=**my_special_field**&meta_value=no
 * or
 * [http://www.mywebsite.com/?json=get_posts&post_type=](http://www.mywebsite.com/?json=get_posts&post_type=)**
   libro**&meta_key=**author**&meta_value=”**armando** “
 * Anything you say, have made mobile applications using as wordpress backend and
   json plugin-api, so I have some experience.
 * P.S. Sorry for the bad English but I speak Spanish and use google translate 🙂
   hehe
 * /****
    **EN ESPAÑOL PARA MIS PAISANOS** *****/ Hola rjme,
 * Es facil, cuando solicited una consulta al sistema, usa los parametros meta_key&
   meta_value como filtros, es decir:
 * Si el campo personalizado que creaste se llama special_field y tiene como posibles
   valores 1 o 0 tu consulta deberia ser algo asi:
 * [http://www.mywebsite.com/?json=get_posts&post_type=post&meta_key=special_field&meta_value=1](http://www.mywebsite.com/?json=get_posts&post_type=post&meta_key=special_field&meta_value=1)
   or =0
 * segun quieras filtrar ya sea por 1 o por 0.
 * Si tienes otro campo personalizado que se llama my_special_field con posible 
   valores yes or not tu consulta quedaria asi:
 * [http://www.mywebsite.com/?json=get_posts&post_type=post&meta_key=my_special_field&meta_value=yes](http://www.mywebsite.com/?json=get_posts&post_type=post&meta_key=my_special_field&meta_value=yes)
 * or
 * [http://www.mywebsite.com/?json=get_posts&post_type=post&meta_key=my_special_field&meta_value=no](http://www.mywebsite.com/?json=get_posts&post_type=post&meta_key=my_special_field&meta_value=no)
 * Es todo, con eso puedes filtrar los valores devueltos basado en campo personalizado.
 * Recuerda que puedes usar otros parametros consultando WP_Query y viendo que funcionalidades
   te provee.
 * [https://codex.wordpress.org/Class_Reference/WP_Query](https://codex.wordpress.org/Class_Reference/WP_Query)
 * Por cierto, el parametro post_type=post es opcional, pero lo puedes usar en casos
   donde por ejemplo hayas creado un tipo de post personalizado por ejemplo Artistas,
   Libros, ya que de esa manera puedes obtener solo resultados de ese tipo de post
   por ejemplo:
 * [http://www.mywebsite.com/?json=get_posts&post_type=artista&meta_key=my_special_field&meta_value=no](http://www.mywebsite.com/?json=get_posts&post_type=artista&meta_key=my_special_field&meta_value=no)
 * or
 * [http://www.mywebsite.com/?json=get_posts&post_type=libro&meta_key=author&meta_value=”armando&#8221](http://www.mywebsite.com/?json=get_posts&post_type=libro&meta_key=author&meta_value=”armando&#8221);
 * Cualquier cosa me dices, he realizado aplicaciones moviles usando como backend
   wordpress y el plugin json-api, asi que tengo algo de experiencia.
 * P.D. Lamento el mal ingles pero hablo español y use google translate jeje 🙂
 *  Plugin Author [dphiffer](https://wordpress.org/support/users/dphiffer/)
 * (@dphiffer)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/request-by-a-specific-custom-fields/#post-6223570)
 * This is an impressive response, and in multiple languages no less! Thanks cristophergv!
 *  [cristophergv](https://wordpress.org/support/users/cristophergv/)
 * (@cristophergv)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/request-by-a-specific-custom-fields/#post-6223571)
 * To you dphiffer your plugin has helped me very much indeed. Thanks to him I have
   done many projects and lately over mobiles apps.
 * This is just my bit to your project.
 *  Plugin Author [dphiffer](https://wordpress.org/support/users/dphiffer/)
 * (@dphiffer)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/request-by-a-specific-custom-fields/#post-6223572)
 * Gonna mark this as resolved.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Request by a specific custom fields’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/json-api.svg)
 * [JSON API](https://wordpress.org/plugins/json-api/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/json-api/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/json-api/)
 * [Active Topics](https://wordpress.org/support/plugin/json-api/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/json-api/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/json-api/reviews/)

## Tags

 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)
 * [request](https://wordpress.org/support/topic-tag/request/)

 * 6 replies
 * 5 participants
 * Last reply from: [dphiffer](https://wordpress.org/support/users/dphiffer/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/request-by-a-specific-custom-fields/#post-6223572)
 * Status: resolved