BaboonWP 2.0

January 10, 2020

Announcing the immediate availability of version 2.0 of our WordPress theme helper class & JavaScript library, except that from now on we'll call it a theme development framework because that's what it essentially is starting the pretty damn big 2.0 update.


  • BaboonWP is now a WordPress plugin, so to install it simply upload the .zip file from releases to the admin panel.
  • No longer using static methods, so you must first initialize the class with new and set it to a variable.
  • Added conditional callbacks
  • Added templating
  • Added querying content

Conditional callbacks

Conditionals in WordPress you already know about, the is_home, is_page, etc. Since with BaboonWP we are moving away from classic theme files (PHP & HTML mix), we tend to do everything within functions.php. Conditional callbacks help us achieve a number of things. For example, to execute a bunch of code only on a certain page:

$app->is_page('about', function() use($app) {

  // execute stuff here


Or to maybe just execute stuff on the front page:

$app->is_front_page(function() use($app) {

  // execute stuff here



The biggest change to 2.0 is the templating, with what we intend to entirely abandon the old PHP/HTML spaghetti practices that have plagued WordPress for so long. To use BaboonWP templating, simply call the template method, like so:

$app->is_front_page(function() use($app) {

  $app->template('home', [
    'name' => 'John'


That will then load the Handlebars template file located at templates/home.hbs. And then in your handlebars file you can do stuff like this:

Hi, {{name}}.

Querying content

Since WP_Query itself isn't templating language friendly (with its nested objects and stuff), we now have a wrapper on top of it, which you can access with the query method. It doesn't support just about everything yet, but we'll get there.

You can query for stuff, for templates, like this:

$app->is_front_page(function() use($app) {

  $app->template('blog', [
    'posts' => $app->query(['post_type' => 'post'])


As you can see, you can pass the exact same parameters to the query that you can pass to WP_Query.

To conclude

BaboonWP 2.0 is a big update and a shift in a new bold direction, it is by no means ready for use with big and complex WordPress sites just yet, but we'll be adding to it as we use it and need the stuff to be there. All tough the flexibility of it should allow for quite complex stuff already.

There's a lot more that I didn't cover in this post, but you can read in the documentation.