WordPress.org

Forums

JSON API
fetch all custom_fields by JSON-API (1 post)

  1. kassisbassem
    Member
    Posted 2 years ago #

    I want to fetch all custom_fields by JSON-API
    I have done some changes to the Post.php
    `
    function set_custom_fields_value() {
    global $json_api;
    if ($json_api->include_value('custom_fields') &&
    $json_api->query->custom_fields) {
    $keys = explode(',', $json_api->query->custom_fields);
    if (in_array("all", $keys)) {
    $keys=get_meta_keys();
    }
    $wp_custom_fields = get_post_custom($this->id);
    $this->custom_fields = new stdClass();
    foreach ($keys as $key) {
    if (isset($wp_custom_fields[$key])) {
    $this->custom_fields->$key = $wp_custom_fields[$key];
    }
    }
    } else {
    unset($this->custom_fields);
    }
    }

    you have just to add this line custom_fields=all and everything works
    is it possible to include this in the next release ?

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • JSON API
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic