I’ve just installed Wordpress 4.7. One of the mentions in the announcement is that it features a REST API.
My understanding is:
- The Wordpress REST API plugin is not needed anymore, because supposely it has already been merged with core in Wordpress 4.7.
- The Wordpress REST API is enabled by default
However, I notice that in a vanilla Wordpress 4.7 install, none of the endpoints seems to work (for example
How can I tell if the new REST API is really activated? Can the REST API be enabled or disabled with the vanilla Wordpress UI, or should I install a third party plugin to do so?
4.7 has it enabled by default. The easy way to check if it is working is just to visit the example.com/wp-json url, and you should get a list of registered end points there
There is no official option to disable it as (at least there was a talk about it not sure if it got in the release), some core functionality depends on it.
The most obvious things to check for if it is not working is your htaccess rules, and do you have a wp-json directory
/wp-json/wp/v2/posts type URLs don’t work for you, but
/?rest_route=/wp-json/wp/v2/posts does, it means you need to enable pretty permalinks in the settings (suggested by Giles Butler in comments below).
I had 4.7 also thought that REST API was disabled, but I was tricked by the URL. To see the correct URL seek a line looking something like that:
So, using http://mysite?rest_route=/ as the prefix solved my problem. For instance to recover the posts is enought to type: http://mysite?rest_route=/wp/json
I couldn’t find on documentation that the query param was needed. Was I the only one?
If REST API isn’t working out-of-box or after a fresh install and after typing in
then you would need to simply activate your “permalinks” as post_name located:
Or if you do not wish to activate permalinks, you can simply type:
Man, I wish WordPress would update their Rest handbook to be more user-friendly. I like the old version of docs 🙂
I see you have fixed the issue but leaving my solution here as it worked for me too. I had this same issue when updating from beta15 to the core api in wp 4.7 Turns out the issue was that I had some plugins that were using a deprecated function register_api_field which I changed to register_rest_field according to this note in the changelog:
BREAKING CHANGE: Rename register_api_field() to register_rest_field().
Introduces a register_api_field() function for backwards compat, which
calls _doing_it_wrong(). However, register_api_field() won’t ever be
committed to WordPress core, so you should update your function calls.