The difference is that in Transitional mode you’ll be able to use the exact same template in AMP as non-AMP. Also, you’ll be able to write theme templates the normal way in WordPress. You can still override templates for AMP responses, however. To do that, you’ll need to specify a template_dir
.
For example, if you want to serve a different single.php
in AMP than non-AMP, you can create a directory like amp-templates
in your theme and then put a single.php
inside of it; you then tell the plugin about this directory via adding this to your theme’s functions.php
:
add_theme_support( 'amp', array(
'template_dir' => 'amp-templates',
) );
For more on this, see https://amp-wp.org/documentation/how-the-plugin-works/amp-plugin-serving-strategies/
Nevertheless, it is better to not override the template if you can help it. The AMP version should ideally be the same as the non-AMP version. If you need to have two separate template partials in the template for AMP vs non-AMP, you can use the is_amp_endpoint()
function in the theme’s regular template file to check if it is rendering an AMP page or not. For example:
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
// Put AMP code here.
} else {
// Put non-AMP code here.
}
In this way, you don’t need to create an entirely separate template file.