Created
September 8, 2017 13:07
-
-
Save damiencarbery/33f82e99ce42469fa3ccda86bdc2a1de to your computer and use it in GitHub Desktop.
Demonstration of the pagetemplater.php plugin - https://github.com/damiencarbery/page-templater/blob/master/pagetemplater.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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