WP REST API Query Demo Theme

A demonstration theme.

On GitHub

I’ve pushed a demo WordPress theme to GitHub to let the code speak.
In an effort of laziness below is the README file contents and a movie. Because we all love movies.

REST Query Demo Theme

A one page silly stupid WordPres theme illustrating the use of the REST Query plugin, the REST API plugin and Handlebars in its PHP and JS versions.

Installation

  • Download the theme .zip file and extract it in your local WordPress theme folder or clone it there:
git clone https://github.com/lucatume/rest-query-demo-theme.git
  • Run composer update from the theme root folder.
  • Make sure the following plugins are installed and active on the site:
  • WP REST API plugin
  • REST Query plugin
  • Make sure your local installation is running PHP 5.4 or above.

  • Activate the theme.

So?

The relevant part of the theme is the code used to render the content loop initial state using handlebars.php and the following refresh using Backbone and Handlebars.js.
The template re-use possibility comes from a “RESTified” WP_Query done tapping into the REST Query plugin and the WP REST API plugin.
The theme is meant to be a proof of concept and not a “state of the art” approach to WordPress themes; I’ve gone for code simplicity over a more OOP approach for the sake of clarity.
Deactivate JavaScript support on the page to see the theme gracefully degrading to Web 1.0 behaviour and still rock on the REST API.

Next

I’d say more test coverage on the REST Query plugin.

I appreciate your input