Search by

backdrop-dev / template-manager

techkodeninja

Custom templates for registering custom post templates, it works for any object type (e.g., post, term, user, etc.), but does not add any UI elements of its own.

Package info

github.com/backdrop-dev/template-manager

pkg:composer/backdrop-dev/template-manager

Statistics

Installs: 402

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-11-17 21:51 UTC

This package is auto-updated.

Last update: 2026-11-17 21:52:13 UTC


README

Backdrop Template Manager registers custom templates for any object type. It currently adds them to the template drop-down of every post type (or only the post types you pick), and does not add any UI of its own.

The major difference from the typical WordPress page template system is that the template file doesn't have to exist for registration, and templates default to every post type instead of only pages.

Requirements

Installation

composer require backdrop-dev/template-manager

Register the provider when you boot your application:

$app->provider( \Backdrop\Template\Manager\Provider::class );

Usage

Register your templates on the backdrop/templates/register action. It runs on init and passes the templates collection.

add_action( 'backdrop/templates/register', function ( $templates ) {

	// For every post type.
	$templates->add( 'custom-templates/wide.php', [ 'label' => __( 'Wide', 'textdomain' ) ] );

	// Only for pages (`subtype` and `post_types` are the same thing).
	$templates->add( 'custom-templates/landing.php', [
		'label'      => __( 'Landing', 'textdomain' ),
		'post_types' => [ 'page' ]
	] );
} );

The first argument is the template filename relative to your theme. Labels are escaped when they are listed. The collection is also bound in the container as Backdrop\Template\Manager\Templates.

Loading the chosen template on the front end is up to your theme, for example with the template hierarchy package, which looks at the saved _wp_page_template value.

Tests

php tests/run.php

Copyright and Licenses

This project is licensed under the GNU GPL, version 2 or later.

2019–2026 © Benjamin Lu