Skip to content

Instantly share code, notes, and snippets.

View jarednova's full-sized avatar
🗽

Jared Novack jarednova

🗽
View GitHub Profile
<?php
$test = function(){
echo 'test works';
};
$test();
$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
/* mods/side-nav.twig */
class __TwigTemplate_0a76428590b54c4ba53bab18b8522f90b76d43e3ebb0782a476f00875fbab93a extends Twig_Template
{
public function __construct(Twig_Environment $env)
{
parent::__construct($env);
$this->parent = false;
@jarednova
jarednova / require-timber.php
Created January 12, 2015 19:46
Require timber in mu-plugins
<?php
require_once('../plugins/timber-library/timber.php');
Date is {{post.ee.event_start_date}}
$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;
$post = new TimberPost();
$context['post'] = $post;
$category = $post->category(); // this will be a TimberTerm assuming there's 1 or more category assigned to this post
$query = array('posts_per_page' => 6, 'cat' => $category->ID, 'post__not_in' => array($post->ID));
$context['latest'] = Timber::get_posts($query);
//the rest as you had it in your gist
* {
box-sizing: border-box;
}
html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var,
b, i,
{{ post.get_field('my_field") }}
@jarednova
jarednova / functions.php
Last active November 24, 2018 21:00
example of easy shortcodes you can add in functions.php
<?php
add_shortcode( 'section-break', function($attributes = array(), $content = null) {
return '<div class="article-body-section-break"></div>';
} );
add_shortcode( 'email-tease', function($attributes = array(), $content = null) {
return Timber::compile('partials/newsletter.twig', array('context_class' => 'newsletter-signup--in-article', 'text' => $content));
} );