A demonstration theme.
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.
- Download the theme
.zipfile and extract it in your local WordPress theme folder or clone it there:
git clone https://github.com/lucatume/rest-query-demo-theme.git
composer updatefrom 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.
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.
I’d say more test coverage on the REST Query plugin.