WP-API / docs

The content for developer.wordpress.org/rest-api
https://developer.wordpress.org/rest-api
110 stars 615 forks source link

Add tip/gotcha to documentation explaining "plain permalinks" setting and API routes #87

Open haszari opened 4 years ago

haszari commented 4 years ago

If a WordPress site has plain permalinks setting enabled, I believe this affects how you can call/access API routes (please correct me if I'm wrong).

This is the setting I'm referring to:

Screen Shot 2020-03-05 at 8 47 23 AM

When plain permalinks are enabled (the default setting), the curl examples in the docs don't work. For example:

curl http://localhost:8222/wp-json/wp/v2/posts
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<hr>
<address>Apache/2.4.38 (Debian) Server at localhost Port 8222</address>
</body></html>

(The examples work fine with any other permalink option enabed.)

I think there might be other gotchas when WordPress is installed in subfolder on the server. It would be great to add a section to the docs outlining these potential gotchas for new developers.

This section could also include recommendations for how to set up your WordPress install so the examples work out of the box. (Note that plain permalinks is the default setting in WordPress.)