PHP code example of aaronkirkham / wp-timber-view-controller
1. Go to this page and download the library: Download aaronkirkham/wp-timber-view-controller library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aaronkirkham / wp-timber-view-controller example snippets
new Timber\Timber;
new Timber\ViewController;
// look inside /templates/ instead of /views/
Timber::$dirname = 'templates';
add_filter( 'timber_context--404', function( $ctx ) {
$ctx['message'] = '404 - Not Found';
return $ctx;
});
add_filter( 'timber_context--single', function( $ctx ) {
$ctx['post'] = new \Timber\Post();
return $ctx;
});
add_filter( 'timber_context', function( $ctx ) {
$ctx['foo'] = 'bar';
return $ctx;
});