Add Category Name to REST API

The API responses are designed to only return the IDs. You can then fetch the full information for each term. Of course it would not be very performant to make dozens of requests. So instead, the REST API has the concept of embedding resources. If you make your request, but include _embed=1 in your URL, … Read more

How Do I Add User Custom Field to REST API Response?

I got it. Turns out the tutorial I was looking at was old and I was using the wrong WP function. I was using register_api_field but the correct one to use is register_rest_field. It goes like this… function facebook_add_user_data() { register_rest_field( ‘user’, ‘facebook’, array( ‘get_callback’ => ‘rest_get_user_field’, ‘update_callback’ => null, ‘schema’ => null, ) ); … Read more

Android authentication

The best way to authenticate an app with the REST API would be to use OAuth. There’s a good section on OAuth Authentication the REST API documentation site. You will need to install the OAuth1 plugin on your site as well. There are some gotchas with implementing the OAuth plugin on WordPress. I found this … Read more

How to Use JSON With AJAX?

Usually, you can use the global variable ajaxurl instead of any path using admin-ajax.php. More importantly, the PHP function should echo the response before calling wp_die(). Because you haven’t called wp_die(), AJAX is probably waiting for more from PHP. Hope this helps. P.S. What is that ‘json’ string doing where the AJAX fail() function should … Read more

wordpress API for android app

Yes, WP REST API supports user authentication. With this plugin you can use OAuth authentication, application passwords, or basic authentication. Read this. Here you’ll find complete documentation. For JSON API there is a plugin called JSON API Auth. Here you’ll get it. By using it you can implement authentication with JSON API. And yes, as … Read more