PHPackages                             aaronkirkham/wp-timber-view-controller - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. aaronkirkham/wp-timber-view-controller

AbandonedArchivedLibrary[Templating &amp; Views](/categories/templating)

aaronkirkham/wp-timber-view-controller
======================================

A view controller for using Timber on WordPress

v1.2.0(7y ago)226[1 issues](https://github.com/aaronkirkham/wp-timber-view-controller/issues)MITPHP

Since May 3Pushed 7y agoCompare

[ Source](https://github.com/aaronkirkham/wp-timber-view-controller)[ Packagist](https://packagist.org/packages/aaronkirkham/wp-timber-view-controller)[ Docs](https://kirkh.am)[ RSS](/packages/aaronkirkham-wp-timber-view-controller/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

WordPress Timber View Controller
--------------------------------

[](#wordpress-timber-view-controller)

If you're like me and hate writing 2 files to render a twig template for WordPress (e.g. page.php for context and page.twig for markup) then this library is for you. It follows the WordPress Template Hierarchy so you can also create files such as `single-{post_type}.twig`.

### How to use

[](#how-to-use)

Using wp-timber-view-controller is easy.

`composer require aaronkirkham/wp-timber-view-controller`

Then place the following code inside your themes functions.php:

```
require_once( __DIR__ . '/vendor/autoload.php' );

new Timber\Timber;
new Timber\ViewController;
```

and that's it. Your Twig templates will be automatically rendered.

This library uses the internal `Timber::$dirname` variable to locate your templates (default folder is `views`). If you want your files to live in a different folder, you must overwrite this.

```
// look inside /templates/ instead of /views/
Timber::$dirname = 'templates';
```

If you need to add variables to the Timber context, there are handy filters available for that.

### Filter: timber\_context--%TEMPLATE%

[](#filter-timber_context--template)

The `timber_context--%TEMPLATE%` filter (where %TEMPLATE% is the current template name) is fired when the specific template is rendered. This is handy if you want to get posts from WordPress on specific pages.

```
add_filter( 'timber_context--404', function( $ctx ) {
  $ctx['message'] = '404 - Not Found';
  return $ctx;
});
```

```
add_filter( 'timber_context--single', function( $ctx ) {
  $ctx['post'] = new \Timber\Post();
  return $ctx;
});
```

In the above examples, the **message** variable will be available on all pages which are rendered using the 404.twig template, and the **post** variable will be available on all single.twig templates.

### FYI

[](#fyi)

If you want to add data into the context for every template, you should use the `timber_context` filter which is fired by Timber.

```
add_filter( 'timber_context', function( $ctx ) {
  $ctx['foo'] = 'bar';
  return $ctx;
});
```

The variable **foo** is now available on all templates.

### White screen?

[](#white-screen)

If your twig templates are not rendered or you just have a white screen, you should turn on WP\_DEBUG inside wp-config.php to view a hierarchical list of templates that wp-timber-view-controller tried to render. Double check the displayed template path and file names are correct.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Total

3

Last Release

2916d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef449dbf6ebd259a2dae283823fba0f875fafd6951a7fc972f5533dd132d9909?d=identicon)[aaronkirkham](/maintainers/aaronkirkham)

---

Top Contributors

[![aaronkirkham](https://avatars.githubusercontent.com/u/892072?v=4)](https://github.com/aaronkirkham "aaronkirkham (12 commits)")

---

Tags

timbertimber-librarytwigwordpresswordpresstwigtemplatingcontrollerthemestimber

### Embed Badge

![Health badge](/badges/aaronkirkham-wp-timber-view-controller/health.svg)

```
[![Health](https://phpackages.com/badges/aaronkirkham-wp-timber-view-controller/health.svg)](https://phpackages.com/packages/aaronkirkham-wp-timber-view-controller)
```

###  Alternatives

[timber/timber

Create WordPress themes with beautiful OOP code and the Twig Template Engine

5.7k3.4M111](/packages/timber-timber)[hellonico/timber-dump-extension

Provides Symfony VarDumper component for Timber

31197.9k8](/packages/hellonico-timber-dump-extension)[mindkomm/timber-integration-woocommerce

WooCommerce integration for Timber.

11617.6k1](/packages/mindkomm-timber-integration-woocommerce)[thomaswelton/gravatarlib

A lightweight PHP 5.3 OOP library providing easy gravatar integration.

251.1M5](/packages/thomaswelton-gravatarlib)[djboris88/timber-debugger

Composer package which provides some extra debugging options for Timber

1445.3k2](/packages/djboris88-timber-debugger)[frozzare/digster

Twig templates for WordPress

107.1k](/packages/frozzare-digster)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
