If you ever wanted MVC for your WordPress theme's template files without a framework or reduced WordPress performance. If you ever wanted to register template files like single.php
, index.php
, page.php
, and so forth in PHP instead of creating them as files in your theme. All you need is a blank index.php
file and a few lines of code.
Add these classes to your WordPress site (in your functions.php
file is just fine). Then add the following to your theme after creating a blank index.php
file (must be blank) in your theme:
$override = new TemplateOverride(__DIR__ . '/index.php');