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 http://examples.com/wp-json/wp/v2/posts).

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?

  • 1
    Is there discovery tag in page source? <link rel='https://api.w.org/' href='https://example.com/wp-json/' /> Seems to just work on my sites. – Rarst Dec 10 '16 at 17:32
  • @Rarst, if I grep -r "<link rel='https://api.w.org/'" . in the htmldirectory, it returns one hit in file ./wp-includes/rest-api.php with this text: echo "<link rel='https://api.w.org/' href='" . esc_url( $api_root ) . "' />\n"; – Pep Dec 10 '16 at 18:13
  • Not in your source code, in the HTML source of a page from your site in browser. – Rarst Dec 10 '16 at 18:16
  • 1
    @Rarst, yes I see <link href="http://example.com/wp-json/" rel="https://api.w.org/"> – Pep Dec 10 '16 at 18:24
  • What does opening the link in browser get you? With WP_DEBUG enabled? – Rarst Dec 10 '16 at 18:32

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

| improve this answer | |
  • I do not have a wp-json directory under /var/www/html or its subdirectories. I do not seem to have a .htaccess file (other than /var/www/html/wp-content/plugins/akismet/.htaccess, should I have one? – Pep Dec 10 '16 at 17:54
  • @Pep, what webserver do you use? do you have pretty permalinks on? – Mark Kaplun Dec 10 '16 at 17:58
  • Apache. I followed exactly the steps in these tutorials to install Wordpress 4.7 on AWS: docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html and docs.aws.amazon.com/AWSEC2/latest/UserGuide/… – Pep Dec 10 '16 at 18:04
  • not familiar with AWS but if you installed a vanilla wordpress you should have had an .htaccess at the root of your install. If not try to go to setting > permalinks, make sure you are not on the plain setting, save, and then check if an htaccess was generated – Mark Kaplun Dec 10 '16 at 18:12
  • 7
    I found finally the issue. Because I did not know that Permalink would be required for the REST API to work, I skipped during initial setup the step to set AllowOverride All in the <Directory "/var/www/html">section of /etc/httpd/conf/httpd.conf. That's why it was ignoring my changes to .htaccess. Now with a permalink other than PLain, the REST API endpoints work. – Pep Dec 10 '16 at 19:53

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:

link rel='https://api.w.org/' href='http://mysite?rest_route=/' />. 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?

| improve this answer | |
  • Worked for me with wordpress 4.8.x Not sure why this is not documented anywhere. – Anirudha Aug 31 '17 at 11:35
  • 2
    Not the only one. Only found this answer in your comment after 10min searching. Needed to do: www.example.com?rest_route=/wp/v2/posts – Eugene K Feb 7 '18 at 3:50
  • 4
    I think this happens when pretty permalinks aren't enabled. From the docs... "On sites without pretty permalinks, the route is instead added to the URL as the rest_route parameter. For the above example, the full URL would then be example.com/?rest_route=/wp/v2/posts/123" – Giles Butler Jul 19 '18 at 21:36
  • here it is -> developer.wordpress.org/rest-api/#routes-endpoints – deepcell Jan 3 '19 at 16:48
  • Very useful if you are testing out using PHP builtin sever php -S localhost:1234. – Juan Javier Triff Cabanas Sep 2 at 2:22

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:

WP Dashboard->Settings->Permalinks

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 :)

| improve this answer | |

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.