/headless-wordpress

A headless CMS for publishing static JSON for consumption.

Primary LanguagePHPGNU General Public License v2.0GPL-2.0

Headless Wordpress

An example of using wordpress as a headless CMS for publishing static JSON for apps and websites to consume.

Requirements

In order to run these code examples you will need the following:

Running

  • cd wordpress
  • docker-compose up
  • localhost:8080/wp-admin
    • user: root
    • pass: root
  • Party

WTF is going on?

Now that you've got the project running let's look at what is going on here.

Wordpress is an awesome platform, and for a while there ( and still today ) it's pretty widely used, the problem with wordpress and modern frontend development is that it can get bloated, slow, there are security issues, it can be a pain to configure, what ever reason you can imagine someone has an issue with it.

That said it's actually a pretty powerful platform when used right, in this example I am going to go over a bare bones approach to building a headless wordpress site that publishes to s3 as static JSON which can be consumed by your website, app, whatever you want.

Let's take a look at what this takes and how easy it can be to get something up and running and where we can take it.

The Guts

Let's check out the structure of our wordpress installation.

The first thing is that this is using Docker as a base the example wordpress install from my Dockerize All The Things This guide assumes you have knowledge of docker but it's not 100% required for doing something like this.

Wordpress

The install of Wordpress that we have is stripped down to only the essentials wich is just the admin and some base utils in a theme called headless. I've also removed all outbound scripts so there are no comments, no trackbacks, no signup, none of that - just the admin and a base theme.

In the plugins we have 4 plugins.

These plugins are the foundation to what we will be building. With these we will customize our wordpress install with some custom post types, fields and upload to s3 for consuming in your app / project.

Note that for this example I have created a plugin with these as dependencies but that you could roll your own version of something like this and we will cover that.

Check out the Medium Post To Learn More