Created
December 11, 2018 22:54
-
-
Save danielmcclure/67bdf0580bc09540ece1598af7464251 to your computer and use it in GitHub Desktop.
Enable & Customise AMP Compatibility Within WordPress Themes
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
<?php | |
// Enabled Paired Mode (Recommended) | |
add_theme_support( 'amp', array( | |
'paired' => true, | |
) ); | |
// Enabled Native Mode (Less Functional) | |
add_theme_support( 'amp', array( | |
'paired' => false, // Force native mode | |
) ); | |
// Specify Custom Template Directory | |
add_theme_support( 'amp', array( | |
'template_dir' => 'amp-templates', | |
) ); | |
// Enable AMP Templates universally | |
add_theme_support( 'amp', array( | |
'templates_supported' => 'all', | |
) ); | |
// Selectively enable AMP Template Support | |
add_theme_support( 'amp', array) | |
'templates_supported' => array( | |
'is_singilar' => true, | |
'os_search' => false, | |
), | |
) ); | |
/* | |
* NOTE: When using paired mode, use the `is_amp_endpoint` conditional to specificy AMP specific functionality | |
* | |
<?php if ( is_amp_endpoint() ) : ?> | |
on="tap:AMP.setState( { siteNavigationMenuExpanded: ! siteNavigationMenuExpanded } )" | |
[aria-expanded]="siteNavigationMenuExpanded ? 'true' : 'false'" | |
<?php endif; ?> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment