Terms: WordPress has got ‘em, you want ‘em. Categories. Tags. Custom Taxonomies. You don’t care, you’re a fiend. Well let’s get this under control:


//Get a term by its ID
$context['term'] = new Timber\Term(6);
//Get a term when on a term archive page
$context['term_page'] = new Timber\Term();
//Get a term with a slug
$context['team'] = new Timber\Term('patriots');
//Get a team with a slug from a specific taxonomy
$context['st_louis'] = new Timber\Term('cardinals', 'baseball');
Timber::render('index.twig', $context);


<h2>{{term_page.name}} Archives</h2>
    <li>{{st_louis.name}} - {{st_louis.description}}</li>
    <li>{{team.name}} - {{team.description}}</li>


<h2>Team Archives</h2>
    <li>St. Louis Cardinals - Winner of 11 World Series</li>
    <li>New England Patriots - Winner of 6 Super Bowls</li>



Name Type Description
name string the human-friendly name of the term (ex: French Cuisine)
taxonomy string the WordPress taxonomy slug (ex: post_tag or actors)


Name Type Returns/Description
children array
description string
edit_link string
link string
meta string
path string
posts array/bool/null
title string

Class Methods


__construct( mixed/int $tid=null, string $tax="" )

returns: void

Name Type Description
$tid mixed/int
$tax string


__toString( )

returns: string


children( )

returns: array


description( )

returns: string

edit_link( )

returns: string


from( mixed $tid, mixed $taxonomy )

returns: \Timber\static

Name Type Description
$tid mixed
$taxonomy mixed

link( )

returns: string

Returns a full link to the term archive page like http://example.com/category/news


See all posts in: <a href="{{ term.link }}">{{ term.name }}</a>


meta( string $field_name )

returns: string

Retrieves and outputs meta information stored with a term. This will use both data stored under (old) ACF hacks and new (WP 4.6+) where term meta has its own table. If retrieving a special ACF field (repeater, etc.) you can use the output immediately in Twig — no further processing is required.

Name Type Description
$field_name string


<div class="location-info">
  <h2>{{ term.name }}</h2>
  <p>{{ term.meta('address') }}</p>


path( )

returns: string

Returns a relative link (path) to the term archive page like /category/news


See all posts in: <a href="{{ term.path }}">{{ term.name }}</a>


posts( mixed/int/array $numberposts_or_args=10, string $post_type_or_class="any", string $post_class="" )

returns: array/bool/null

Gets posts that have the current term assigned.

Name Type Description
$numberposts_or_args mixed/int/array Optional. Either the number of posts or an array of arguments for the post query that this method is going. to perform. Default 10.
$post_type_or_class string Optional. Either the post type to get or the name of post class to use for the returned posts. Default any.
$post_class string Optional. The name of the post class to use for the returned posts. Default Timber\Post.


<h4>Recent posts in {{ term.name }}</h4>
{% for post in term.posts(3, 'post') %}
        <a href="{{ post.link }}">{{ post.title }}</a>
{% endfor %}

If you need more control over the query that is going to be performed, you can pass your custom query arguments in the first parameter. Twig

<h4>Our branches in {{ region.name }}</h4>
{% for branch in region.posts({
    posts_per_page: -1,
    orderby: 'menu_order'
}, 'branch', 'Branch') %}
        <a href="{{ branch.link }}">{{ branch.title }}</a>
{% endfor %}


title( )

returns: string


update( string $key, mixed $value )

returns: void

Name Type Description
$key string
$value mixed

This class extends \Timber\Core

This class implements \Timber\CoreInterface