Created
February 17, 2019 20:38
-
-
Save waqashassan98/c7461665de693083961dd51489831f1d to your computer and use it in GitHub Desktop.
Load amp templates without plugin wordpress
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
define( 'AMP_QUERY_VAR', 'amp' ); | |
add_rewrite_endpoint(AMP_QUERY_VAR , EP_PERMALINK | EP_PAGES | EP_ROOT); | |
add_filter( 'template_include', 'amp_page_template',99 ); | |
function amp_page_template( $template ) { | |
if( get_query_var( AMP_QUERY_VAR , false ) !== false ) { | |
if ( is_page( 'about-us' ) ) { | |
$new_template = get_template_directory() . '/amp-about-us.php'; | |
return $new_template; | |
} | |
if ( is_home() ) { | |
$new_template = get_template_directory() . '/amp-home.php'; | |
return $new_template; | |
} | |
} | |
return $template; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment