WordPress Workflow With Rest API

No Comments

Over the last decade we’ve seen the accelerating rise of dynamic JavaScript and application programming interface (API) functionality in previously static HTML web pages. In some cases, web pages are easily as robust and complicated as older, desktop counterparts. However, for a long time WordPress had not codified option for developers who wanted to bring these exciting possibilities to their WordPress sites.

That was until a small, dedicated group decided to change all that. Growing out of Google’s 2012 Summer of Code, the group now boasts scores of dedicated contributors and by WordPress 4.5 in 2016, the Rest API was potentially available to any WordPress site.

Wait... What is Rest API?

Where can I find the API on your WordPress site?

If you are running WordPress 4.5 or later, you can see the raw output by going to:  http://yourwordpressdomain.com/wp-json

This might not be too friendly to human eyes, but it is not meant to be.  If you’d like to navigate it visually though, you can install either the JSONView browser extension for Chrome or Firefox, or for power users, Postman for Chrome.

What can I do with Rest API for WordPress?

The basic element of the Rest API in WordPress is something called a “route”.  Routes are URLs that you can use to call objects and collections (groups of objects).  If you are familiar with the core objects of WordPress, you’ll recognize many of these such as users, terms, comments and posts.

For example, if you wanted to call upon and manipulate the post data for your site, you could use this URL:

http://yourwordpressdomain.com/wp-json/wp/v2/posts

Try it on your own WordPress site and it should return 10 posts by default, each already formatted with field names (i.e. title, content, status, date, etc).  All ready for your manipulation via JavaScript!

Experiment with the read aspect of the Rest API and get comfortable with basic concepts like filtering and formatting.  Once you’re comfortable, you can explore the GET and POST functionality to manipulate this data quickly and conveniently for authoring your own plugins!

Resources

 

I'm the front-man of It's WordPress. I come from a diverse array of backgrounds, enjoying the opportunity to expand my knowledge base and skill set by re-inventing myself. I enjoy environments that focus on emerging information, technology and concepts. I put on the technical hat in my early 20s and never really looked back. I'm love technology and the internet, as well as the outdoors and avidly hike, kayak and camp every chance I get.

About Us

We can take you from concept, through design, development and deployment in one seamless process. Whether you choose a self-managed web site or need a continuing support relationship; we've got you covered.

Request Consulation

Ready to transform your vision into a reality? Just looking to see what it takes to get the ball rolling. Tell us about your project and we can help. No spam. No obligation. Just answers.

More from our blog

See all posts