Skip to content

Instantly share code, notes, and snippets.

@damiencarbery
Created September 8, 2017 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damiencarbery/33f82e99ce42469fa3ccda86bdc2a1de to your computer and use it in GitHub Desktop.
Save damiencarbery/33f82e99ce42469fa3ccda86bdc2a1de to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: Page Templater Demo
Plugin URI: http://www.damiencarbery.com/2017/09/grandchild-templates-made-easy/
Description: Demonstrate how to use pagetemplater.php and the included filters
Version: 0.1
Author: Damien Carbery
Author URI: http://www.damiencarbery.com/
*/
// Set the directory to search for template files - files will be in 'templates' subdirectory.
add_filter( 'pagetemplater_templates_dir', 'pt_set_templates_dir' );
function pt_set_templates_dir( $templates_dir ) {
return 'templates';
}
// Remove a template from the list of available templates.
add_filter( 'pagetemplater_templates_found', 'pt_set_templates_list' );
function pt_set_templates_list( $templates ) {
unset( $templates[ 'templates/does-not-exist.php' ] );
return $templates;
}
include_once( plugin_dir_path( __FILE__ ) . 'pagetemplater.php' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment