WordPress as a Headless CMS
Content management systems (CMSs) are very useful, allowing you to create, edit and manage your content as needed.
But as powerful as they might be, traditional CMSs such as WordPress don’t meet everyone’s requirements. In some cases, a higher amount of flexibility is desired. You may, for example, want to integrate your CMS with a different coding methodology and not use the front end so often. In such cases, WordPress may still be the answer, since we can change the way we use it. We can use it as what’s called a headless CMS.
A Headless CMS Defined
In the simplest of terms, a headless CMS is one that has no front end. As such, it includes just the API and the back end that is required to store and manage content, organize data and handle the workflow. There’s no front end display of the said content. Naturally, this means any front-end templates tend to become unnecessary in a headless CMS.
Advantages of Headless CMSs
Perhaps the biggest and most obvious advantage associated with headless CMS architecture is the fact that it offers great flexibility and control to developers. You can control virtually every aspect of development, handle how data is managed, how content is stored in the back end and even decide on the best possible front-end solution for your needs.
With such flexibility, coupled with the fact that every headless CMS comes with its own API for managing calls to and from the back end, you can save a good deal of development time. It’s easier to reuse existing modules, push updates and bug fixes and perform other similar tasks when working with a headless CMS.
Why You Might Use WordPress as a Headless CMS
We’ve seen the various advantages that headless CMSs bring to the table.
In general, a headless CMS is preferable in cases where a traditional CMS may not fit in, or be too restrictive in nature. Take, for example, the case of mobile development. You can easily use API calls in a headless CMS to deliver content to an iOS or Android platform. Similarly, you can make use of JavaScript frameworks in your apps and rely on headless
Using WordPress as a Headless CMS
WordPress has three major parts:
- the database, where the content is stored
- the admin panel to manage the content (API)
- the HTML view, or front end, to display the content.
Step One: Setting up WordPress
It’s important that you use a fresh installation of WordPress. Considering the fact that there are various tutorials out there on how to install WordPress, and the official documentation too is rather detailed on this step, we will be skipping the installation details here.
Furthermore, most web hosting providers nowadays offer one-click install feature for WordPress. Just bear in mind: change the database and table prefixes from the default wp_
values to something else, and use strong passwords
Step One: Setting up WordPress
Remember that we mentioned the front end has little role to play in a headless CMS? WordPress has a big ecosystem that’s famous for its amazing themes. But we don’t need any of that. With that said, though, WordPress does need a theme to run, even if the front end isn’t going to be used. A good idea, therefore, is to just use a blank theme.
Doing More with Headless WordPress
For most practical purposes, you may need to add additional content fields when working with WordPress as a headless CMS. In order to do that, using the popular Advanced Custom Fields (ACF) plugin is a good solution.
ACF, as any WordPress developer would tell you, lets you easily add custom fields to your content, which you can then call via and API.
However, note that when you’re calling custom fields via a RESTful API, you may need to employ the ACF to REST API plugin as well so as to properly structure the calls. This plugin can be used to expose ACF endpoints for use with the WordPress REST API.
A lesser-known and rarely used WordPress plugin also deserves a special mention here — WordPress Headless. This plugin lets you create a headless WordPress CMS within minutes. It removes the front end and ensures that post permalinks go to the editor, not the view (logged in users only). If you’re trying to quickly get started with development and wish to convert a WordPress installation into a headless CMS, WordPress Headless plugin can do just that without you having to set things up yourself. Obviously, the API calls and other development tasks will still need to be handled by you.
Source : https://www.sitepoint.com/wordpress-headless-cms/