Created
October 2, 2018 20:45
-
-
Save joshfeck/cffca80358305709025f08979de85a60 to your computer and use it in GitHub Desktop.
Hydrogen theme template that preserves the global $post object.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @package Gantry 5 Theme | |
* @author RocketTheme http://www.rockettheme.com | |
* @copyright Copyright (C) 2007 - 2017 RocketTheme, LLC | |
* @license GNU/GPLv2 and later | |
* | |
* http://www.gnu.org/licenses/gpl-2.0.html | |
*/ | |
defined('ABSPATH') or die; | |
use Timber\Timber; | |
/* | |
* The Template for displaying all single posts | |
*/ | |
global $post; | |
$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'] = $theme->render('partials/page_head.html.twig', $context); | |
$altered_post = Timber::query_post(); | |
$context['post'] = $altered_post; | |
$context['wp_title'] .= ' - ' . $altered_post->title(); | |
Timber::render(['single-' . $post->ID . '.html.twig', 'single-' . $post->post_type . '.html.twig', 'single.html.twig'], $context); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment