Skip to content

Instantly share code, notes, and snippets.

View jarednova's full-sized avatar
🗽

Jared Novack jarednova

🗽
View GitHub Profile
$artists = Timber::get_posts($artist_args);
foreach( $artists as $artist ) {
$connected = new WP_Query( array(
'connected_type' => 'portfolios_to_artists',
'connected_items' => $artist,
'nopaging' => true
) );
$artist->portfolios = Timber::get_posts($connected);
}
$data['artists'] = $artists;
Date is {{post.ee.event_start_date}}
@jarednova
jarednova / require-timber.php
Created January 12, 2015 19:46
Require timber in mu-plugins
<?php
require_once('../plugins/timber-library/timber.php');
<?php
/* mods/side-nav.twig */
class __TwigTemplate_0a76428590b54c4ba53bab18b8522f90b76d43e3ebb0782a476f00875fbab93a extends Twig_Template
{
public function __construct(Twig_Environment $env)
{
parent::__construct($env);
$this->parent = false;
$context = Timber::get_context();
$context['slides'] = Timber::get_posts('post_type=slides');
$context['pages'] = Timber::get_posts('post_type=page&posts_per_page=2');
$context['portfolio'] = Timber::get_posts('post_type=portfolio');
$context['posts'] = Timber::get_posts(); //leave blank for default page query
Timber::render('front-page.twig', $context);
<?php
$test = function(){
echo 'test works';
};
$test();
<?php
$context = Timber::get_context();
$context['work'] = Timber::get_posts('post_type=work&numberposts=25');
$context['posts'] = Timber::get_posts();
Timber::render('index.twig', $context);
<?php
get_header();
echo 'whatever'.get_the_title();
the_content();
$data = array();
$data['post'] = new TimberPost();
Timber::render('article-meta.twig', $data);
{% for sub_post in TimberPost(post.get_field('my_repeater').sub_post) %}
<h2>{{sub_post.title}}</h2>
{% endfor %}