Last active
July 21, 2016 16:40
-
-
Save johnregan3/e713437b5cbf449af9a35c16890da00f to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Add a custom AMP template file. | |
* | |
* Registers templates in a /templates subdirectory. | |
* | |
* @filter amp_post_template_file | |
* | |
* @param string $file The file name input. | |
* @param string $type The type of template. | |
* @param object $post WP Post Object. | |
* | |
* @return string | |
*/ | |
function jr3_amp_custom_templates( $file, $type, $post ) { | |
if ( 'single' === $type ) { | |
$file = dirname( __FILE__ ) . '/templates/single.php'; | |
} elseif ( 'style' === $type ) { | |
$file = dirname( __FILE__ ) . '/templates/style.php'; | |
} | |
return $file; | |
} | |
add_filter( 'amp_post_template_file', 'jr3_amp_custom_templates', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment