WordPress is a popular CMS (Content Management System). If you want to host your own website using your website then WordPress is best to start. It doesn’t require any programming knowledge to start! The user interface is straightforward and very easy to use. With each update, WordPress is getting more and more secured. The minimal threats that occurs are from 3rd party plugins. If you have a good understanding picking up the right plugin, then you are safe.
Okay! Today we will focus on more on the built in REST API to quickly find relevant information about a website. Many many many websites are now live with WordPress, and in most of them this REST API is live.
How to find Total Posts Published Using REST API?
$ curl -X OPTIONS -i http://demo.wp-api.org/wp-json/wp/v2/posts
If you don’t want to use a terminal just, fire up a browser and use the slug ‘/wp-json/wp/v2/posts’. The result page is a JSON formatted output. Which will list out latest 10 posts published by the system. However, total post count is not present there. To find out the total open the Developers Tools. In Firefox, press ‘Ctrl+E’, then press ‘F5’ to refresh. Find the header of the URL request. The total post number will be in ‘x-wp-total’ segment. Thats it! Now you know how many posts are live in the website!
To know more about WordPress REST API, visit REST API Handbook published by WordPress.