-4
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() ) {

            $template = get_template_directory() .  '/amp-single.php';

        } 

    }

    return $template;
}
cabrerahector
  • 3,653
  • 4
  • 16
  • 27
  • Does this answer your question? [Adding AMP pages to Wordpress manually without a plugin](https://stackoverflow.com/questions/39771761/adding-amp-pages-to-wordpress-manually-without-a-plugin) – cabrerahector Apr 08 '21 at 18:11

1 Answers1

0

If you're looking to make your site AMP compatible without a plugin it would take a lot more work than the function referenced. Have you tried the official AMP plugin? I help out in the support forums if you want to post the question there, happy to help out from there.