Are there server performance benefits to fetching only specific fields when querying the REST API?

I understand that having less data being downloaded improves the experience to the end user, but my question is related to the actual server performance, would the response be faster? Would adding _fields[]=id&_fields[]=title, etc… to the above url improve server performance? No it would not, and for several reasons. When you ask for a post … Read more

Is there a way to get protected meta fields through any of the available built-in WordPress APIs? (xmlrpc, wp-json)

To me, the simplest solution would be creating additional field in JSON response and populating it with selected post meta: function create_api_posts_meta_field() { // “tribe_venue” is your post type name, // “protected-fields” is a name for new JSON field register_rest_field( ‘tribe_venue’, ‘protected-fields’, [ ‘get_callback’ => ‘get_post_meta_for_api’, ‘schema’ => null, ] ); } add_action( ‘rest_api_init’, ‘create_api_posts_meta_field’ … Read more

WP REST API only returning partial list of users

To anyone who might still be hitting this problem, here’s a checklist: Make sure you are authenticated AND your user has the list_users capability. Example: When adding a custom role, I make sure to add the list_users capability. The user should also be logged in (what authenticated means) when making the request. By default, only … Read more

Implementing Isomorphic JavaScript (React JS) in WordPress?

I don’t think using React.js without Node.js (or at least V8 or rhino etc) counts as isomorphic, as isomorphic means that you are building JavaScript to run in the browser AND on the server. Specifically, using WordPress certainly means you aren’t doing isomorphic javascript (its PHP software). What you could do is use WordPress as … Read more

Show popular post in another php website via WP REST JSON API

I will give you a small answer to your update, doing this with the WP API. The API have the possibilities to use the WP_Query like also in core, but about the get parameters in the url. A URL to pull content from Post Status would look like this: http://example.com/wp-json/posts To pull content with WP_Query … Read more

Query WP REST API v2 by multiple meta keys

Adding a custom endpoint is pretty straightforward. I also modified the url to look more like http://example.com/wp-json/namespace/v2/posts?filter[meta_value][month]=12&filter[meta_value][year]=2015 function wp_json_namespace_v2__init() { // create json-api endpoint add_action(‘rest_api_init’, function () { // http://example.com/wp-json/namespace/v2/posts?filter[meta_value][month]=12&filter[meta_value][year]=2015 register_rest_route(‘namespace/v2’, ‘/posts’, array ( ‘methods’ => ‘GET’, ‘callback’ => ‘wp_json_namespace_v2__posts’, ‘permission_callback’ => function (WP_REST_Request $request) { return true; } )); }); // handle the request … Read more