function testPostOnSingleQueryNoParams()
 {
     $post_id = $this->factory->post->create();
     $this->go_to(home_url('/?p=' . $post_id));
     $post = Timber::query_post();
     $this->assertEquals($post_id, $post->ID);
     $this->assertEquals($post_id, get_the_ID());
 }
 /**
  * Render the slider widget.
  * @todo TODO
  * @since 1.0.0
  */
 function widget($args, $instance)
 {
     extract($args);
     $query_args = array('post_type' => 'slide', 'posts_per_page' => $instance['per_page'], 'offset' => $instance['offset']);
     $widget = array('interval' => $instance['interval'], 'pause' => $instance['pause'], 'wrap' => $instance['wrap'], 'parallax' => $instance['parallax'], 'second_image' => $instance['second_image'], 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title);
     $context = Maera()->cache->get_context();
     $context['slide'] = Timber::query_post();
     $context['slides'] = Timber::get_posts($query_args);
     $context['widget'] = $widget;
     Timber::render('slider.twig', $context, Maera()->cache->cache_duration());
     wp_reset_postdata();
 }
 /**
  * Render the menu widget.
  * @todo TODO
  * @since 1.0.0
  */
 function widget($args, $instance)
 {
     extract($args);
     $query_args = array('post_type' => 'restaurant_item', 'posts_per_page' => $instance['per_page']);
     $widget = array('title' => apply_filters('widget_title', $instance['title']), 'show_price' => $instance['show_price'], 'show_featured_images' => $instance['show_featured_images'], 'show_tags' => $instance['show_tags'], 'show_menu_link' => $instance['show_menu_link'], 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title);
     $context = Maera()->cache->get_context();
     $context['menu_item'] = Timber::query_post();
     $context['menu_items'] = Timber::get_posts($query_args);
     $context['widget'] = $widget;
     Timber::render('menu.twig', $context, Maera()->cache->cache_duration());
     wp_reset_postdata();
 }
 /**
  * Render the widget on the front end.
  * @todo TODO
  * @since 1.0.0
  */
 function widget($args, $instance)
 {
     extract($args);
     if (isset($instance['term']) && 'any' != $instance['term']) {
         $tax_query = array(array('taxonomy' => $instance['taxonomy'], 'terms' => $instance['term']));
     } else {
         $tax_query = '';
     }
     $query_args = array('post_type' => $instance['post_type'], 'tax_query' => $tax_query, 'posts_per_page' => $instance['per_page'], 'offset' => $instance['offset']);
     $widget = array('title' => apply_filters('widget_title', $instance['title']), 'thumb' => $instance['thumb'], 'thumb_float' => $instance['thumb_float'], 'thumb_width' => $instance['thumb_width'], 'thumb_height' => $instance['thumb_height'], 'excerpt_length' => $instance['excerpt_length'], 'more_text' => $instance['more_text'], 'post_title_size' => $instance['post_title_size'], 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title);
     $context = Maera()->cache->get_context();
     $context['post'] = Timber::query_post();
     $context['posts'] = Timber::get_posts($query_args);
     $context['widget'] = $widget;
     Timber::render('widget-extended-posts.twig', $context, Maera()->cache->cache_duration());
     wp_reset_query();
 }
 /**
  * Modify the Timber global context
  * @param  [type] $context [description]
  * @return [type]          [description]
  */
 function maera_res_context($context)
 {
     $context['currency'] = get_theme_mod('currency', '$');
     $context['facebook_link'] = get_theme_mod('facebook_link', 'http://facebook.com/');
     $context['twitter_link'] = get_theme_mod('twitter_link', 'http://twitter.com/');
     $context['googleplus_link'] = get_theme_mod('googleplus_link', 'http://plus.google.com/');
     $context['youtube_link'] = get_theme_mod('youtube_link', 'http://youtube.com');
     $context['menu_sections'] = Timber::get_terms('restaurant_item_menu_section');
     $context['sidebar']['section_1'] = Timber::get_widgets('section_1');
     $context['sidebar']['section_2'] = Timber::get_widgets('section_2');
     $context['sidebar']['section_3'] = Timber::get_widgets('section_3');
     $context['sidebar']['section_4'] = Timber::get_widgets('section_4');
     $context['sidebar']['section_5'] = Timber::get_widgets('section_5');
     $context['sidebar']['footer'] = Timber::get_widgets('footer');
     if (is_post_type_archive('restaurant_item') && rp_is_restaurant()) {
         $query_args = array('post_type' => 'restaurant_item', 'posts_per_page' => 999, 'order' => get_theme_mod('restaurant_order', 'ASC'), 'order_by' => get_theme_mod('restaurant_order_by', 'ID'));
         $context['menu_item'] = Timber::query_post();
         $context['menu_items'] = Timber::get_posts($query_args);
     }
     return $context;
 }
<?php

/**
 * Archive page for esdeveniment custom post type
 *
 * Methods for TimberHelper can be found in the /lib sub-directory
 *
 * @package  wp-softcatala
 */
//JS and Styles related to the page
wp_enqueue_script('sc-js-esdeveniments', get_template_directory_uri() . '/static/js/esdeveniments.js', array('sc-js-main'), WP_SOFTCATALA_VERSION, true);
wp_enqueue_script('sc-js-novetats', get_template_directory_uri() . '/static/js/novetats.js', array('sc-js-main'), WP_SOFTCATALA_VERSION, true);
wp_localize_script('sc-js-novetats', 'scajax', array('ajax_url' => admin_url('admin-ajax.php')));
//Template initialization
$templates = array('archive-esdeveniment.twig');
$post = Timber::query_post(get_option('page_for_posts'));
$context_holder['post'] = $post;
$context_holder['content_title'] = 'Esdeveniments';
$context_holder['links'] = $post->get_field('link');
$context_holder['sidebar_top'] = Timber::get_widgets('sidebar_top');
$context_holder['sidebar_elements'] = array('baixades.twig', 'links.twig');
$context_holder['sidebar_bottom'] = Timber::get_widgets('sidebar_bottom');
//Filters population
$context_holder['cat_link'] = get_category_link(get_query_var('esdeveniment_cat'));
$context_holder['categories']['temes'] = Timber::get_terms('esdeveniment_cat');
$context_holder['filters'] = get_the_event_filters();
//Search and filters
$search = get_query_var('cerca');
$tema = get_query_var('tema');
$filter = get_query_var('data');
$filterdate = get_final_time($filter);
示例#7
0
<?php

/**
 * The Template for displaying all single posts
 *
 * Methods for TimberHelper can be found in the /lib sub-directory
 *
 * @package  WordPress
 * @subpackage  Timber
 * @since    Timber 0.1
 */
$context = Timber::get_context();
$post = Timber::query_post();
$context['post'] = $post;
$context['comment_form'] = TimberHelper::get_comment_form();
if (post_password_required($post->ID)) {
    Timber::render('single-password.twig', $context);
} else {
    Timber::render(array('single-' . $post->ID . '.twig', 'single-' . $post->post_type . '.twig', 'single.twig', 'single-recipes.twig', 'single-reasons.twig', 'single-foods.twig'), $context);
}
 function testBlankQueryPost()
 {
     $pid = $this->factory->post->create();
     $this->go_to(home_url('/?p=' . $pid));
     $post = Timber::query_post();
     $this->assertEquals($pid, $post->ID);
 }
示例#9
0
<?php

/**
 * @package   Gantry 5 Theme
 * @author    RocketTheme http://www.rockettheme.com
 * @copyright Copyright (C) 2007 - 2015 RocketTheme, LLC
 * @license   GNU/GPLv2 and later
 *
 * http://www.gnu.org/licenses/gpl-2.0.html
 */
defined('ABSPATH') or die;
/*
 * The template for displaying BBPress pages
 */
$gantry = Gantry\Framework\Gantry::instance();
$theme = $gantry['theme'];
// We need to render contents of <head> before plugin content gets added.
$context = Timber::get_context();
$context['page_head'] = $gantry->isCompatible('5.1.5') ? $theme->render('partials/page_head.html.twig', $context) : null;
$context['posts'] = Timber::query_post();
$context['content'] = TimberHelper::ob_function('the_content');
Timber::render('bbpress.html.twig', $context);