Skip to content

Timber

A faster, easier and more powerful way to build WordPress themes.

Timber helps you create fully-customized WordPress themes faster with more sustainable code. With Timber, you write your HTML using the Twig Template Engine separate from your PHP files. This cleans-up your theme code so your PHP file can focus on supplying the data and logic, while your twig file can focus 100% on the display and HTML.

Why Timber?

It's for rookies.
People new to WordPress will like how it reduces the WordPress-specific knowledge required to theme a website.

It's got cred.
Timber is a 5-star rated plugin that’s been installed over 500,000 times.

It's for pros.
Pros can take advantage of object-oriented patterns that adhere to DRY and MVC principles.

It's got support.
If you need help, check out the crystal clear documentation, or enlist one of our recommended agencies or experts.

I can’t tell you how many sites I’ve built with WordPress, but I can tell you the exact moment my mind was blown when I first used Timber.

TJ Fogarty CSS Tricks

How Timber Works

Separate logic from presentation
With Timber you manage your theme in PHP and Twig (HTML) files. This separates the logic (getting stuff from WordPress) from presentation (adding tags, classes, etc.). Object-oriented posts, terms, users and more make it easy to interact across WordPress objects just like Rails, Django, Laravel, and other platforms.

single.php
$context = Timber::context();
$context['foo'] = 'Bar!';
$context['post'] = Timber::get_post();
Timber::render('single.twig', $context);
single.twig
{% extends "base.twig" %}
{% block content %}
   <h1 class="big-title">{{ foo }}</h1>
   <h2>{{ post.title }}</h2>
   <img src="{{ post.thumbnail.src }}" />
   <div class="body"> {{ post.content }} </div>
{% endblock %}

Unlock the power of Twig templates
Easily share re-usable markup between template files that you can nest, extend and interact in ways you only dreamed of previously.

single.twig
{% extends "base.twig" %}
{% block content %} I have something to say {% endblock %}
base.twig
{% include "html-header.twig" %} 

{% block content %} 
   Default stuff here 
{% endblock %} 

<footer> 
   {% include "footer-markup.twg" %}
</footer>

Use it a little or use it a lot
Timber works with your existing themes to unlock new power. You don't have to throw out everything you already have working. The best tools evolve into your workflow: I didn't know I wanted to use jQuery or SASS until I started using them. Bit-by-bit they replaced the 'old' ways of doing things until I couldn't imagine life without them. Timber lets you start with just a bit. Say you want to just include an HTML snippet with a variable from your database:

home.php
$data['welcome_message'] = get_option('welcome_message');
Timber::render('welcome.twig', $data);
welcome.php
{# welcome.twig #}
<p class="intro">{{ welcome_message }}</p>

Very very quickly falling love with Timber...it's fantastic, the bits I thought would be a pain seem to be incredibly easy so far.

Addzy Cullen Creative Developer, Orbital Design

Technology at Upstatement
See our other open source projects

Open Source