Skip to content

Instantly share code, notes, and snippets.

@CrisHazzard
Created October 21, 2016 13:15
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 CrisHazzard/1cffbb693c87c52d86d729b26646168b to your computer and use it in GitHub Desktop.
Save CrisHazzard/1cffbb693c87c52d86d729b26646168b to your computer and use it in GitHub Desktop.
Redirect Pages with /AMP/ to a different Wordpress Page Template on HikingGuy.com
// ****************************************************************************************************
// AMP support
define( 'AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) );
add_rewrite_endpoint( AMP_QUERY_VAR, EP_PERMALINK );
add_filter( 'template_include', 'amp_page_template', 99 );
function amp_page_template( $template ) {
if( get_query_var( AMP_QUERY_VAR, false ) !== false ) {
if ( is_single() ) {
// amp-single.php is my page template for AMP
$template = get_template_directory() . '/amp-single.php';
}
}
return $template;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment