timber / timber
Create WordPress themes with beautiful OOP code and the Twig Template Engine
Fund package maintenance!
Open Collective
timber
Installs: 2 378 458
Dependents: 104
Suggesters: 4
Security: 1
Stars: 5 538
Watchers: 130
Forks: 516
Open Issues: 48
Requires
- php: ^8.1
- twig/twig: ^3.5
Requires (Dev)
- ergebnis/composer-normalize: ^2.28
- php-parallel-lint/php-parallel-lint: ^1.3
- php-stubs/acf-pro-stubs: ^6.0
- php-stubs/wp-cli-stubs: ^2.0
- phpro/grumphp: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.7
- phpunit/phpunit: ^9.0
- rector/rector: ^1.0
- squizlabs/php_codesniffer: ^3.0
- symplify/easy-coding-standard: ^12.2
- szepeviktor/phpstan-wordpress: ^1.1
- twig/cache-extra: ^3.3
- wpackagist-plugin/advanced-custom-fields: ^6.0
- wpackagist-plugin/co-authors-plus: ^3.6
- yoast/wp-test-utils: ^1.2
Suggests
- php-coveralls/php-coveralls: ^2.0 for code coverage
- twig/cache-extra: For using the cache tag in Twig
- 2.x-dev
- v2.3.0
- v2.2.0
- v2.1.0
- 2.0.0
- 2.0.0-rc.1
- 2.0.0-beta.2
- 2.0.0-beta.1
- 2.0.0-alpha.6
- 2.0.0-alpha.5
- 2.0.0-alpha.4
- 2.0.0-alpha.3
- 2.0.0-alpha.2
- 2.0.0-alpha.1
- 1.x-dev
- 1.24.1
- 1.24.0
- 1.23.1
- 1.23.0
- 1.22.1
- 1.22.0
- 1.21.0
- 1.20.0
- 1.19.2
- 1.19.1
- 1.19.0
- 1.18.2
- 1.18.1
- 1.18.0
- 1.17.0
- 1.16.0
- 1.15.2
- 1.15.1
- 1.15.0
- 1.14.0
- 1.13.0
- 1.12.1
- 1.12.0
- 1.11.0
- 1.10.1
- 1.10.0
- 1.9.5
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.4
- 1.8.3
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.1
- 1.7.0
- 1.6.0
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.1
- 1.4.0
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.3.0-rc2
- 1.3.0-rc1
- 1.3.0-beta
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.12
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7.1
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 1.0.0-rc3
- 1.0-rc2
- v1.0-rc.1
- 0.22.6
- 0.22.5
- 0.22.4
- 0.22.3
- 0.22.2
- 0.22.1
- 0.22.0
- 0.21.10
- 0.21.9
- 0.21.8
- 0.21.7
- 0.21.6
- 0.21.5
- 0.21.4
- 0.21.3
- 0.21.2
- 0.21.0
- 0.20.10
- 0.20.9
- 0.20.8
- 0.20.7
- 0.20.6
- 0.20.5
- 0.20.4
- 0.20.3
- 0.20.2
- 0.20.1
- 0.20.0
- 0.19.2
- 0.19.1
- 0.19.0
- 0.18.1
- 0.18.0
- 0.17.2
- 0.17.0
- 0.16.8
- 0.16.6
- dev-doc-i18n
- dev-dependabot/github_actions/lycheeverse/lychee-action-2.1.0
- dev-release-please--branches--2.x
- dev-3008-bug-deprecated-preg_replace-passing-null-to-parameter-3-subject-of-type-arraystring-is-deprecated
- dev-wp-plugin
- dev-release-checklist-2x
This package is auto-updated.
Last update: 2024-11-20 19:51:41 UTC
README
Timber 2.0
By Jared Novack (@jarednova), Lukas Gächter (@lgaechter), Nicolas Lemoine (@nlemoine), Erik van der Bas (website), Coby Tamayo (@cobytamayo), Upstatement and hundreds of other GitHub contributors:
⚠️ Important information about the Timber plugin ⚠️
With the release of Timber 2.0, Composer is the only supported install method. We are unable to continue releasing or supporting Timber as a plugin on WordPress.org. We advise everyone to switch to the Composer based install of Timber 1 as a first step as soon as possible. If you need PHP 8.2 support you will have to switch to Timber 2.0.
For more information and a list of additional resources, please visit this discussion.
What is Timber?
Because WordPress is awesome, but The Loop isn’t.
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, for example, your PHP file can focus on being the data/logic, while your Twig file can focus 100% on the HTML and display.
This is what Timber's .twig
files look like (from this Hello World example)
{% extends "base.twig" %} {% block content %} <h1 class="big-title">{{ foo }}</h1> <h2 class="post-title">{{ post.title }}</h2> <img src="{{ post.thumbnail.src }}" /> <div class="body"> {{ post.content }} </div> {% endblock %}
Once Timber is installed, it gives any WordPress theme the ability to take advantage of the power of Twig and other Timber features.
Documentation
Installation
Follow the Installation Guide for how to install Timber using Composer.
What Now?
Setup the Timber Starter Theme. Once you have that installed in your WordPress setup, continue reading the Getting Started guide to Themeing.
Timber’s mission
Timber is a tool for developers who want to translate their HTML into high-quality WordPress themes through an intuitive, consistent and fully-accessible interface.
- Intuitive: The API is written to be user-centric around a programmer's expectations.
- Consistent: WordPress objects can be accessed through common polymorphic properties like slug, ID and name.
- Accessible: No black boxes. Every effort is made so the developer has access to 100% of their HTML.
What does it look like?
Nothing. Timber is meant for you to build a theme on. Like underscores it comes style-free, because you're the style expert. Instead, Timber handles the logic you need to make a kick-ass looking site.
Who is it good for?
Timber is great for any WordPress developer who cares about writing good, maintainable code. It helps teams of designers and developers working together. At Upstatement we made Timber because while our entire team needs to participate in building WordPress sites, not everyone knows the ins-and-outs of the_loop(), codex and PHP (nor should they). With Timber your best WordPress engineer can focus on building the .php
files with requests from WordPress and pass the data into .twig
files. Once there, designers can easily mark-up data and build out a site's look-and-feel.
Should I use it?
Timber is MIT-licensed, so please use in personal or commercial work. Just don't re-sell it. Timber is used on tens of thousands of sites (and tons more we don't know about)
Timber 1
You can find the code for Timber 1 on the 1.x branch and read the Timber 1 documentation over here.
Links
Related & Official Projects
- Twig The template language used by Timber.
- Timber Starter Theme The "_s" of Timber to give you an easy start to the most basic theme you can build upon and customize.
- wp-i18n-twig WP CLI Command to grab translatable strings from Twig files.
- Timber Debug Bar Adds a debug bar panel that will show you which template is in-use and the data sent to your twig file.
Related Timber Projects
- Editor for Timber Edit your Twig files from the WordPress admin
- Pine A CLI installer for Timber
- Query Monitor Twig Profile An add-on for Query Monitor to see what's going on inside your Twig files (automatically works with Timber!)
- Timber ACF WP Blocks Easy ACF Gutenberg blocks creation
- Timber CLI A CLI for Timber
- Timber Commented Include Debug output via HTML comments before and after each include statement in Twig
- Timber Debugger Package that provides extra debugging options for Timber
- Timber Dump Extension Debug output with nice formatting
- Timber Photon Plug-in to use JetPack's free Photon image manipulation and CDN with Timber
- Timber VS Code Extension Snippets for Timber in Visual Studio Code
- Timber Sugar A catch-all for goodies to use w Timber
- Timber WebLink Extension Provides Twig functions to manage the Link HTTP header needed for Web Linking when using HTTP/2 Server Push as well as Resource Hints
- Timmy Advanced image manipulation for Timber
Projects that use Timber
- Branch Bootstrap 3 + Timber = Branch starter theme!
- Flynt a component based WordPress starter theme built on Timber and ACF Pro
- Gantry5 a framework for theme development
- Hozokit a component based starter theme
- Juniper Starter pack that incorporates Timber and Bedrock
- Seedling a starter theme using Bootstrap 4
Helpful Links
- CSS Tricks introduction to Timber by @tjFogarty
- Twig for Timber Cheatsheet by @laras126
- Timber Cheatsheet by @taotiwordpress
- TutsPlus A guide to getting started by @ahmadawais
Reporting Security Issues
To disclose a security issue to our team, please submit a report via GitHub.
Support
Please post on StackOverflow under the "Timber" tag. Please use GitHub issues only for specific bugs, feature requests and other types of issues.
Contributing & Community
We love PRs! Read the Contributor Guidelines for more info. Say hello, share your tips/work, and spread the love on Twitter at @TimberWP.
Sponsor us
Since 2013 our goal at Timber is to create a library to that helps you create fully-customized WordPress themes faster with more sustainable code.
Through the collaborative efforts of both our dedicated team and countless contributors, we have invested numerous hours in maintaining and enhancing Timber. To keep doing that, we rely on the invaluable support of our sponsors.
Are you a WordPress pro or part of an agency who relies on Timber? Keep the magic alive by becoming a sponsor! By becoming a sponsor, you contribute to the continuous maintenance and enhancement of Timber, ultimately benefiting developers worldwide.
Gold Sponsors
Our backers
Documentation
The Official Documentation for Timber is generated from the contents of this repository:
- Documentation for classes and functions is auto generated. Any changes to the Reference section of the docs should be made by editing the function’s DocBlock. For inline documentation, we follow the WordPress PHP Documentation Standards.
- To make a change to one of the guides, edit the relevant file in the
docs
directory.