Title: Couldn&#039;t get all custom fields
Last modified: August 31, 2016

---

# Couldn't get all custom fields

 *  [Dule95D](https://wordpress.org/support/users/dule95d/)
 * (@dule95d)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/couldnt-get-all-custom-fields/)
 * [http://www.nadji-ekipu.org/dontforget/api/get_post/?post_id=14](http://www.nadji-ekipu.org/dontforget/api/get_post/?post_id=14)
 * This is the link of json i’m trying to parse, but i’m getting only from custom
   fields one field “description” and i should get two more fields i have included
   in post.
 * I have seen in one question here that one guy post this code:
 * if (!isset($_GET[‘custom_fields’])) {
    $_GET[‘custom_fields’] = ‘description,
   price, rating’; }
 * and it helped me getting description, but couldn’t get price and rating. Can 
   you help me getting more than one custom fields?
 * [https://wordpress.org/plugins/json-api/](https://wordpress.org/plugins/json-api/)

Viewing 1 replies (of 1 total)

 *  [monkeypunch3](https://wordpress.org/support/users/monkeypunch3/)
 * (@monkeypunch3)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/couldnt-get-all-custom-fields/#post-6932113)
 * For me, all the custom field data is coming back automatically.
 * In model/posts.php do you have this code:
 *     ```
       function set_custom_fields_value() {
           global $json_api;
           if ($json_api->include_value('custom_fields')) {
             $wp_custom_fields = get_post_custom($this->id);
             $this->custom_fields = new stdClass();
             if ($json_api->query->custom_fields) {
               $keys = explode(',', $json_api->query->custom_fields);
             }
             foreach ($wp_custom_fields as $key => $value) {
               if ($json_api->query->custom_fields) {
                 if (in_array($key, $keys)) {
                   $this->custom_fields->$key = $wp_custom_fields[$key];
                 }
               } else if (substr($key, 0, 1) != '_') {
                 $this->custom_fields->$key = $wp_custom_fields[$key];
               }
             }
           } else {
             unset($this->custom_fields);
           }
         }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Couldn't get all 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/)

 * 1 reply
 * 2 participants
 * Last reply from: [monkeypunch3](https://wordpress.org/support/users/monkeypunch3/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/couldnt-get-all-custom-fields/#post-6932113)
 * Status: not resolved