Plumbing: Templates

  • PHP
  • WordPress

Modern verions of WordPress have extended the “Page Template” feature to all custom post types, but by default WordPress will still only look in one location to find those templates.

This tool just allows you to define your own directory to put templates in, and allows you to define that directory on a per-post-type basis, if you want to:

use Livy\Plumbing\Templates\register_template_directory;

// Define templates for the built-in `page` type


// Define templates for the `event` post type:
register_template_directory('event-templates', 'event');

(The name is part of an intended series of tiny little Composer packages for WordPress that add simple bits of functionality.)