amp_is_canonical()
Description #
Whether this is in 'canonical mode'.
Themes can register support for this with add_theme_support( AMP_Theme_Support::SLUG )
:
add_theme_support( AMP_Theme_Support::SLUG );
Code language: PHP (php)
This will serve templates in AMP-first, allowing you to use AMP components in your theme templates.
If you want to make available in transitional mode, where templates are served in AMP or non-AMP documents, do:
add_theme_support( AMP_Theme_Support::SLUG, array(
'paired' => true,
) );
Code language: PHP (php)
Transitional mode is also implied if you define a template_dir
:
add_theme_support( AMP_Theme_Support::SLUG, array(
'template_dir' => 'amp',
) );
Code language: PHP (php)
If you want to have AMP-specific templates in addition to serving AMP-first, do:
add_theme_support( AMP_Theme_Support::SLUG, array(
'paired' => false,
'template_dir' => 'amp',
) );
Code language: PHP (php)
See also
- {@see AMP_Theme_Support::read_theme_support()}