Home > CMS Tutorial > WordPress > About the basic use of WordPress REST API

About the basic use of WordPress REST API

藏色散人
Release: 2020-05-17 14:28:35
forward
3900 people have browsed it

The following column WordPress Website Building Tutorial will introduce you to the basic use of WordPress REST API. I hope it will be helpful to friends in need!

About the basic use of WordPress REST API

The WordPress system opens REST API by 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/wp- json/wp/v2/posts

Page list/wp-json/wp/v2/pages

User list/wp-json/wp/v2/ users

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 the complete resource API link, please visit

https://developer.wordpress.org/rest-api/reference/
Copy after login

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/
Copy after login

After installation and activation, except for the logged-in administrator, other users have no permission to access data.

In order to make JSON data easy to read in the browser, you can install related extensions:

Chrome :

https://chrome.google.com/webstore/detail/json-viewer/aimiinbnnkboelefkjlenlgimcabobli?utm_source=chrome-ntp-icon
Copy after login

For more WordPress technical articles, please visit WordPress TipsColumn!

The above is the detailed content of About the basic use of WordPress REST API. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template