Toolbox for Beaver Builder

Timber and Twig introduction

What is Timber and what is Twig? Let's start with Twig first: Twig is a flexible, fast, and secure template engine for PHP. It compiles templates down to plain optimized PHP code. The overhead compared to regular PHP code is reduced to the very minimum. Timber is a library of commands for WordPress that feeds data about your WordPress page into the Twig engine, so that you can write the templates to generate the output. When installing the Timber-library, it will install the Twig engine that comes with it.

Twig is extendable through Timber. You can write your own set of re-usable templates and include them on the ACF Fields Module or Timber Posts Module. Change them in one place instead of on all modules. Save those carefully crafted Twig templates and use them on other projects. Or include them as a plugin.

Relationship, Flexible Content and Post Object

Twig can be used for any field but it is extremely useful for relational fieldtypes. Because you can type your template inside the Editor, you will get immediate results and see what you're doing!

Once you master the fundamentals of the Twig engine, you will quickly be able to produce layouts that wouldn't be possible or would require you to write function and filters in your functions.php and upload them to your server.

Last modified: June 15th, 2019