The WP REST API infrastructure was introduced in WordPress 4.4. The introduction of this infrastructure allows WordPress developers to now use WordPress as a headless CMS. A headless CMS has its frontend component (the head) stripped and removed from its backend, and what remains is a backend delivering content via an API. Some common use cases for headless CMS are as follows:
Serving data to other web applications
Mobile Apps
Websites and web apps built with MVC-style JavaScript frameworks
Developers can install the WP REST API plugin to expose endpoints for WordPress for posts, pages, media and users. Developers can also extend the WordPress core REST infrastructure to register their own endpoints for custom post types and WordPress options.
The WP REST API plugin will expose database content via JSON. This data can be used by developers to create sites using JavaScript frameworks such as React and also use the JSON data in mobile apps.
Bronson will explain and demonstrate how you can use WordPress and the WP REST API to create a website that uses React on the frontend and WordPress on the backend as a headless CMS.
2. Overview
@bronsonquick
● Who Am I?
● What Is A Headless CMS?
● How Does It Work?
● Why?
● Who Is Using It?
● Questions
● Thanks
3. Who Am I?
@bronsonquick
● Senior WordPress Developer
● Core Contributor
● Maintainer Of Chassis
● Occasional WordCamp Organiser - WordCamp Gold Coast & WordCamp Brisbane
● Massive Smashing Pumpkins Fan
● Vinyl Addict
● Guitar Fan
4. What Is A Headless CMS?
@bronsonquick
● A headless CMS is used only for data capture, storage, and delivery,
making it frontend agnostic. Its data can be displayed using any
frontend technology, whether in a browser, mobile application,
syndication, or elsewhere.
6. Decoupling content management
@bronsonquick
● Developers are not locked into the templating engine provided
by the CMS. The CMS might be written in PHP, but developers
working in languages like JavaScript, Java, Ruby, and Swift can
use an API to retrieve, store and display data
7. Why WordPress?
@bronsonquick
● Without WordPress you’d have to create all this from scratch:
● Admin interface.
● User management and capabilities.
● DB structure.
● Server setup - WordPress will run on most web hosts!
● The existing content might already be in WordPress!
● Custom post types, taxonomies and custom meta.
● REST API
8. New Ways To Work
@bronsonquick
● An internal dev team might want to use React, Angular or Ember for the frontend.
● Content creators can still get to use a familiar UI to enter data.
● Extend the REST API Infrastructure with custom endpoints.
● Serve different content to different devices and platforms.
● You’ll still be writing WordPress code to serve the content in different views.
10. How?
@bronsonquick
● Extend the REST API Infrastructure with custom endpoints.
● Install the WP REST API plugin.
● Add Authentication - Cookie based, OAuth or OAuth2.
● Write frontend or app code in your preferred language of choice.
14. Change Your Workflow
@bronsonquick
● Work alongside companies with existing in-house developers
● Your JavaScript developer no longer needs to learn PHP
● Your PHP developer no longer needs to learn JavaScript
● You can hire highly skilled and focused frontend and backend developers
● Hire more sys ops people for scaling and new infrastructure