The following columnWordPress Tutorialwill introduce you to the basic use of WordPress REST API. I hope it will be helpful to friends in need!
The WordPress system opensREST APIby default, that is to say, in addition to outputting content in HTML format,
can also output content in JSON format Output article/user/comments and other data.
The reason why JSON data format response is supported is because currently various smart terminal devices, such as mobile phones/tablets/TVs/routers/home appliances/toys, etc.,
have to communicate with the cloud server. Communication, and the data required by the terminal device does not necessarily have to be presented to the user after parsing HTML by the browser.
So JSON, a data format specification that is easy to write/read/parse, is usually used for data communication.
If you have deployed WordPress, you can get data in JSON format through the corresponding link:
Link format example:
Article list
Page list
User list
Replace the example domain name with your own domain name. If the page returns a 404 error, you need to set the redirection rules of the WEB proxy server (Nginx).
For complete resource API link, please visithttps://developer.wordpress.org/rest-api/reference/
here It can be seen that if the website wants to provide data interface services for other devices, it can be used directly without development costs.
If you do not want your website to open the REST API, you can disable this feature by installing the plug-in Disable REST API.
Plug-in address:https://wordpress.org/plugins/disable-json-api/
After installation and activation, in addition to the logged-in administrator, other users No permission to access data.
In order to make JSON data easy to read in the browser, you can install related extensions:
Chrome:
The above is the detailed content of Basic usage of WordPress REST API. For more information, please follow other related articles on the PHP Chinese website!