1. Go to this page and download the library: Download hoku/twig-wordpress 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/ */
hoku / twig-wordpress example snippets
define('TWP___TWIG_ROOT', get_template_directory().'/twig/');
define('TWP___TEMPLATE_PATH', TWP___TWIG_ROOT.'templates/'); // This could be omitted because it's the default
function my_post($post)
{
$post->content = get_the_content();
}
add_action('the_post', 'my_post');
function my_environment($environment)
{
$environment->addFunction('query_posts', new Twig_Function_Function('query_posts'));
}
add_action('TWP__environemnt', 'my_environment');