Timber Logo

You are reading the documentation for Timber v1.x. Switch to the documentation for Timber v2.x.

Timber\Site

Timber\Site gives you access to information you need about your site. In Multisite setups, you can get info on other sites in your network.

PHP

<?php
$context = Timber::context();
$other_site_id = 2;
$context['other_site'] = new Timber\Site($other_site_id);
Timber::render('index.twig', $context);

Twig

My site is called {{site.name}}, another site on my network is {{other_site.name}}

HTML

My site is called Jared's blog, another site on my network is Upstatement.com

Overview #

Properties #

NameTypeDescription
admin_emailstringthe admin email address set in the WP admin panel
charsetstring
descriptionstring
idintthe ID of a site in multisite
languagestringthe language setting ex: en-US
multisitebooltrue if multisite, false if plain ole' WordPress
namestring
pingback_urlstringfor people who like trackback spam
theme\Timber\Theme
titlestring
rdfstring

Methods #

NameTypeReturns/Description
linkstring

Class Methods #

__construct #

__construct( mixed/string/int $site_name_or_id=null )

returns: void

Constructs a Timber\Site object

NameTypeDescription
$site_name_or_idmixed/string/int

PHP

<?php
//multisite setup
$site = new Timber\Site(1);
$site_two = new Timber\Site("My Cool Site");
//non-multisite
$site = new Timber\Site();

__get #

__get( string $field )

returns: mixed

NameTypeDescription
$fieldstring

icon #

icon( )

returns: void


language_attributes #

language_attributes( )

returns: string

Returns the language attributes that you're looking for


link( )

returns: string

Returns the link to the site's home.

Twig

<a href="{{ site.link }}" title="Home">
<img src="/wp-content/uploads/logo.png" alt="Logo for some stupid thing" />
</a>

HTML

<a href="http://example.org" title="Home">
<img src="/wp-content/uploads/logo.png" alt="Logo for some stupid thing" />
</a>

url #

DEPRECATED 1.0.4

url( )

returns: string


icon_multisite #

icon_multisite( mixed $site_id )

returns: void

NameTypeDescription
$site_idmixed

switch_to_blog #

switch_to_blog( string/\Timber\integer/null $site_name_or_id )

returns: \Timber\integer with the ID of the new blog

Switches to the blog requested in the request

NameTypeDescription
$site_name_or_idstring/\Timber\integer/null

This class extends \Timber\Core

This class implements \Timber\CoreInterface