Wallace: A Free WordPress Theme Built on the WP REST API and Angular

Bradley Kirby released version 1.0 of his Wallace WordPress theme today. The theme is built using the WP REST API and Angular 2. Kirby has been working on Wallace for the past two years and has rewritten it several times in order to keep pace with changes in the REST API and Angular.

If you view the Wallace demo, you’ll notice that the theme is super fast because the interface is rendered on the client side with JavaScript.

“It really opens a whole new world of possibility for WordPress themes,” Kirby said. “For this release I’ve primarily focused on smooth page transitions. That’s just not possible with the traditional server-rendered themes. But I think there’s a lot of really cool customization techniques that the API allows for, too. That’s what I’m hoping to explore next.”

Although React has emerged as the most popular JavaScript framework for front-end development in 2016, Kirby said he chose Angular mostly because he learned it first.

“I really like the prescriptive nature of Angular,” Kirby said. “There’s a ‘right’ way to do things that you’ll find in example projects and all the functionality comes with the framework itself. With React you have to use a collection of third-party libraries with various maintainers. With Angular, it’s all Google, and all one repository. I think React is a perfectly fine framework, and they actually share a lot of concepts.”

Wallace currently only supports posts, but Kirby plans to implement more core WordPress features, including pages, comments, searching, and category filtering. He said those features shouldn’t be too difficult to implement now that the frame is there.

“From a programming perspective, this was way more difficult to create than a PHP-rendered theme, because you get so much ‘for free’ with the PHP theming API that you don’t get when you’re just making raw requests to the REST API,” Kirby said. The primary advantage of theming with the API is more instantaneous interactions with the content, but creating API-driven themes is not yet as easy as the old way of theming.

Kirby said he is actively exploring the idea of submitting Wallace to WordPress.org, but the Theme Review Team does not permit the use of Twig templates.

“I’ve brought it up with the team that approves themes, and they didn’t like that I was using the Twig templating library on the PHP side,” Kirby said. “So I’d have to maintain two versions of the theme if I were to submit it to the directory.” Kirby hasn’t ruled it out yet and said he will probably revisit the idea next year.

“Twig templates mirror Angular templates really nicely,” Kirby said. “It cuts down on the maintenance burden quite a bit, because I have to exactly mirror the templates on the server side and the client side. That would be more difficult if I had to construct PHP echo strings, the typical WordPress template way.”

Wallace is integrated with the Customizer and will disable its JavaScript when it detects the Customizer is open, reverting back to a “normal” theme. Currently the only option users can customize is the site icon and site title. Wallace does not yet offer support for setting a static front page.

The next items on Wallace’s roadmap are adding more core features into the theme. Kirby said he is also exploring the idea of creating a commercial magazine theme in the future.

“I think the real killer use case for this way of developing themes is e-commerce, but I want to get a good solid magazine style premium theme done before I tackle that,” Kirby said.

There are 37 comments

Comments are closed.