ShoutOut

Share
Share
Share
Twitter

WordPress Rest API Example

A simple WordPress Rest API example. The WordPress API is little known outside of developer circles, with businesses understandably having no idea what it is or why they should be bothered knowing about it. It is a huge subject but I’ll try and explain here the what, why and an example (the how is another story).

What is the WordPress API?

What is an API?

API = Application Programming Interface, enabling external applications or programmes to see and update the information on your application.

What is WordPress?

WordPress is known mainly as something people have their website built on, with most websites being used a marketing tool for their business, not as an application. If you have a membership website built on WordPress then you are starting to step into the world of a WordPress applications.

Combine the two – WordPress API

The WordPress API was first introduced in 2016, and what it does is open up your content to the outside world. If you have a WordPress site, and if your developer hasn’t switched it off (the default is that it is switched on) you can see all the posts and pages of your website on the link ‘<your website name>/wp-json’. This is you first touch on the WordPress API, it let’s anyone or anything read your posts and pages in what I can only call in none techie terms something similar to an excel spreadsheet.

How would someone use it?

So if someone wanted to write a program and use your post information, then they can fetch it from that link. If you don’t want just anyone to pick up your posts, then you can shut it down or give a user name and password to the developer so their programme can access it.

Why do I care as an owner of a WordPress site?

If you are investing in content development and or seo then you are building up a repository of data. Now you may well be spending money and time on the design of your website which is being built using WordPress but it is important to view them as two different items – the design and your data.

Real World WordPress API Example

Having control of your data, that is posts, pages, images and more (but we’ll talk about that again) means that you can ask someone else to use it and build something interesting.

The example below is a website which is consuming a WordPress rest api on a website www.localradar.co.uk. It is picking up the post content, including the post’s geolocations. The website is fully written in javascript, it doesn’t know anything about WordPress. It accesses the WordPress Rest API to fetch the data including the associated images.

And yes, maybe you don’t want to have another website using your post information, but what if, for example, you had a set of books, properties, knowledge base, that you didn’t want on your main site but maybe on a subdomain, so perhaps books.yourdomain.co.uk. You can still manage the data on your main WordPress site, but your subdomain can pick it up and display it. You are free to use whichever developer you want, you just tell them where the data is. Managing the data like this within WordPress, means you are in full control of it 🧐.

Globe Example can be seen here

WordPress API globe example
In this article
Custom SEO Packages
SEO
How Much Does SEO Cost And Is It Worth It?
wordpress api globe example
WordPress Rest API Example
wordpress mobile updater example
WordPress Updating From Your Mobile
Interactive Map WordPress
SEO
Interactive Maps and Charts on WordPress