function testAmpersandInTitle() { $post_id = $this->factory->post->create(array('post_title' => 'Jared & Lauren')); $post = new TimberPost($post_id); $this->assertEquals(get_the_title($post_id), $post->title()); $this->assertEquals(get_the_title($post_id), $post->post_title); }
public function get_title() { if (!$this->title) { $this->title = $this->post->title(); } return $this->title; }
/** * Determine the context that will be used by the content() method */ public function context() { global $wp_query; $context = Maera()->cache->get_context(); $post = new TimberPost(); $context['post'] = $post; $context['posts'] = Timber::get_posts(); // Compatibility hack or plugins that change the content. if ($this->plugins_compatibility()) { $context['content'] = maera_get_echo('the_content'); } if (is_singular()) { $context['wp_title'] .= ' - ' . $post->title(); } if (is_search()) { $context['title'] = __('Search results for ', 'maera') . get_search_query(); } if (is_archive() || is_home()) { $context['posts'] = Timber::query_posts(false, 'TimberPost'); $context['title'] = get_the_archive_title(); if (is_author()) { $author = new TimberUser($wp_query->query_vars['author']); $context['author'] = $author; } } if (class_exists('WooCommerce')) { global $product; $context['product'] = $product; } return $context; }
function testPage() { $pid = $this->factory->post->create(array('post_type' => 'page', 'post_title' => 'My Page')); $post = new TimberPost($pid); $this->assertEquals($pid, $post->ID); $this->assertEquals('My Page', $post->title()); }
<?php /** * Template Name: Homepage */ if (!class_exists('Timber')) { echo 'Timber not activated. Make sure you activate the plugin in <a href="/wp-admin/plugins.php#timber">/wp-admin/plugins.php</a>'; return; } $context = Timber::get_context(); $pi = new TimberPost(); $produtos = new TimberPost($pi->produtos); $context['post'] = $pi->title(); Timber::render(array('home.twig'), $context);
<?php /* Template Name: Person */ /** * The template for displaying people pages. * * This is the template that displays all pages by default. * Please note that this is the wordpress construct of pages * and that other 'pages' on your wordpress site will use a * different template. * */ $data = Timber::get_context(); $pi = new TimberPost(); $data['post'] = $pi; $data['wp_title'] = $pi->title() . ' - About Upstatement'; $data['post']->links = get_field('links'); foreach ($data['post']->links as &$link) { $link['class'] = 'ss-social'; if (isset($link['icon']) && $link['icon'] == 'home') { $link['class'] = ' '; } } $data['post']->image = new TimberImage($pi->image); $data['post']->image_mobile = new TimberImage($pi->image_mobile); Timber::render(array('page-person-' . $pi->post_name . '.twig', 'page-person.twig'), $data);
<?php /** * The Template for displaying all single posts * * Methods for TimberHelper can be found in the /functions sub-directory * * @package WordPress * @subpackage Timber * @since Timber 0.1 */ $context = Timber::get_context(); $post = new TimberPost(); $context['post'] = $post; $context['wp_title'] .= ' - ' . $post->title(); $context['comment_form'] = TimberHelper::get_comment_form(); Timber::render(array('single-' . $post->ID . '.twig', 'single-' . $post->post_type . '.twig', 'single.twig'), $context);