autoloading - maxcal/Twigpress GitHub Wiki
#Autoloading
Twigpress can mimic Worpress the Wordpress template inheritance cascade but load twig files instead. This is useful if you intend need a drop in PHP replacement.
The theme only needs a index.php file which tells Twigpress to mimic Worpress normal template inheritance and load the appropriate Twig template.
// /themes/yourTheme/index.php
$Twigpress->registerGlobalFunctions();
echo $Twigpress->autoDisplay($wp_query);
A query for:
example.org/?author=1
Would do the following lookup:
-
Is there a PHP file with higher specificity? If so let it have the query (this is done by Wordpress).
- author-max.php
- author-1.php
- author.php
- index.php
-
Twigpress uses the following cascade to look in its path for templates:
- author-max.html.twig
- author-max.twig
- author-1.html.twig
- author-1.twig
- author.html.twig
- author.twig
- index.html.twig
- index.twig
- error