Home > CMS Tutorial > WordPress > body text

Basic usage of WordPress REST API

藏色散人
Release: 2019-10-02 14:00:37
forward
9924 people have browsed it

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

Basic usage 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 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:

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

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!