I’ve used quite many CMS over time and WordPress is one of my favorites. From a developers point of view, it let’s you hook into it pretty easy. And from a users perspective, it’s admin UI is simple enough, well designed and recognized by many people. Together with Advanced Custom Fields (must have wordpress plugin), WordPress gives you an extremly easy way to create dynamic content with an super adjustable UI.

The problem is that you end up with a great, fully organized editor UI, but a front-end that has to be written in php, meaning you have to merge php logic with html. Spaghetti.

Also, WordPress isn’t known to be very fast, which is an even more important factor today when you create mobile websites.

Last, you lack control over your process. Lets say you want to flush some content before WordPress begins to make database calls (which is particulary important when developing mobile first sites). You want to be able to know exactly when something can be flushed, and where to put the logic that takes a little more time to process.

There are, of course, some traditionall solutions to these challenges. WordPress has some template engines (not many, but they exist). And to make WordPress fast, you can always use some kind of cache, be it a plugin (WP Total cache etc) for smaller sites, or a full cache system (Varnish etc) for bigger solutions.

But if you want to gain some more benefits, as well as addressing the challenges above, you can use nodejs.

Node?

Node might not be the first thing that comes into mind, but it helps more than you might think. If we let WordPress handle all admin UI, but write templates that render JSON instead of HTML, we can create a front node server that proxies WordPress and gives us these benefits:

a. Use any javascript template engine we want (many to choose from). b. Cache any content we want, as long as we want, when we want. c. Control the flow. Flush when we want. Process things when we want. d. Almost no difference in WordPress devlopment, the only difference beeing that you write your templates to output json instead og html

Since express makes it so easy to set up a server, we almost don’t need to code at all. Simplified, these are the only steps you need to make to create a front end server in node:

  1. Set up wordpress as usual.
  2. Instead of creating index.php in your template folder that renders html, let it render json.
  3. Set up a nodejs server with express.
  4. Proxy all requests directly to worpress, but when you get thet answer, merge the json data with your template engine.
  5. Cache the result.

Author

ateetagrawal