underpin / post-template-loader
Post Template Loader for Underpin
1.1.0
2021-11-24 21:33 UTC
Requires
- underpin/underpin: ^2.0
This package is auto-updated.
Last update: 2024-10-25 03:31:03 UTC
README
Loader That assists with adding post templates to a WordPress website.
Installation
Using Composer
composer require underpin/post-template-loader
Manually
This plugin uses a built-in autoloader, so as long as it is required before Underpin, it should work as-expected.
require_once(__DIR__ . '/underpin-post-templates/post-templates.php');
Setup
- Install Underpin. See Underpin Docs
- Register new post templates as-needed.
Example
A very basic example could look something like this.
\Underpin\underpin()->post_templates()->add( 'template', [ 'name' => 'Template Name', // Shows in dropdown 'template' => 'template-name' // Shows when post template is fetched, and in REST ] );
Alternatively, you can extend post template
and reference the extended class directly, like so:
underpin()->post_templates()->add('key','Namespace\To\Class');