You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is this a support or usage question? Please post to StackOverflow using the Timber tag
Expected behavior
To be able to Initialise Timber from the Parent Theme and have the Child theme use it.
Actual behavior
Fatal error: Uncaught Error: Class 'Timber\Timber' not found in /Users/jake/Code/wp/wp-content/themes/framework-child/functions.php:23 Stack trace: #0 /Users/jake/Code/wp/wp-settings.php(426): include() #1 /Users/jake/Code/wp/wp-config.php(89): require_once('/Users/jake...') #2 /Users/jake/Code/wp/wp-load.php(37): require_once('/Users/jake...') #3 /Users/jake/Code/wp/wp-admin/admin.php(31): require_once('/Users/jake...') #4 /Users/jake/Code/wp/wp-admin/index.php(10): require_once('/Users/jake...') #5 {main} thrown in /Users/jake/Code/wp/wp-content/themes/framework-child/functions.php on line 23
Steps to reproduce behavior
Parent functions.php:
if (file_exists($composer = DIR . '/vendor/autoload.php')) {
require $composer;
}
// Initialise Timber
$timber = new \Timber\Timber();
require_once DIR . '/app/timber.php';
Child functions.php:
if (file_exists($composer = DIR . '/vendor/autoload.php')) {
require $composer;
}
// Initialise Timber
$timber = new \Timber\Timber();
require_once DIR . '/app/timber.php';
add_filter('timber_context', array($this, 'add_to_context'));
add_filter('get_twig', array($this, 'add_to_twig'));
add_action('init', array($this, 'register_post_types'));
add_action('init', array($this, 'register_taxonomies'));
parent::__construct();
}
public function register_post_types()
{
//this is where you can register custom post types
}
public function register_taxonomies()
{
//this is where you can register custom taxonomies
}
public function add_to_context($context)
{
$context['menu'] = new TimberMenu();
$context['site'] = $this;
return $context;
}
public function add_to_twig($twig)
{
/* this is where you can add your own functions to twig */
$twig->addExtension(new Twig_Extension_StringLoader());
return $twig;
}
}
new Framework();
What version of WordPress, PHP and Timber are you using?
WordPress 4.9.4 PHP 7.1 Timber 1.7.0
How did you install Timber? (for example, from GitHub, Composer/Packagist, WP.org?)
Composer/Packagist
The text was updated successfully, but these errors were encountered:
Is this a support or usage question? Please post to StackOverflow using the Timber tag
Expected behavior
To be able to Initialise Timber from the Parent Theme and have the Child theme use it.
Actual behavior
Fatal error: Uncaught Error: Class 'Timber\Timber' not found in /Users/jake/Code/wp/wp-content/themes/framework-child/functions.php:23 Stack trace: #0 /Users/jake/Code/wp/wp-settings.php(426): include() #1 /Users/jake/Code/wp/wp-config.php(89): require_once('/Users/jake...') #2 /Users/jake/Code/wp/wp-load.php(37): require_once('/Users/jake...') #3 /Users/jake/Code/wp/wp-admin/admin.php(31): require_once('/Users/jake...') #4 /Users/jake/Code/wp/wp-admin/index.php(10): require_once('/Users/jake...') #5 {main} thrown in /Users/jake/Code/wp/wp-content/themes/framework-child/functions.php on line 23
Steps to reproduce behavior
Parent functions.php:
if (file_exists($composer = DIR . '/vendor/autoload.php')) {
require $composer;
}
// Initialise Timber
$timber = new \Timber\Timber();
require_once DIR . '/app/timber.php';
Child functions.php:
if (file_exists($composer = DIR . '/vendor/autoload.php')) {
require $composer;
}
// Initialise Timber
$timber = new \Timber\Timber();
require_once DIR . '/app/timber.php';
Both Parent & Child app/timber.php
$timber = new \Timber\Timber();
Timber::$dirname = array('resources/views');
class Framework extends Timber\Site
{
public function __construct()
{
add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat' ) );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'menus' );
add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) );
}
new Framework();
What version of WordPress, PHP and Timber are you using?
WordPress 4.9.4 PHP 7.1 Timber 1.7.0
How did you install Timber? (for example, from GitHub, Composer/Packagist, WP.org?)
Composer/Packagist
The text was updated successfully, but these errors were encountered: