@vengador Note that comments in 0.7 are not implemented for the post templates. These templates are going to be deprecated in favor adding amp
theme support to your theme as a whole. You can see an example of such a theme at https://github.com/xwp/ampconf
Theme running on a demo site (with comments): https://ampdemo.xwp.io/2018/02/06/are-you-there-lebron-its-me-lebron-a-superstars-ultimate-pep-talk/
This is a “native AMP” theme where there aren’t two versions of URLs for AMP and canonical. The amp
theme support still allows for you to have a paired mode, with different template being served for AMP vs canonical. How you do this in 0.7-beta1 is by putting the following in your theme’s functions.php
:
add_action( 'after_setup_theme', function() {
add_theme_support( 'amp', array(
'template_dir' => 'amp/',
'available_callback' => 'is_singular',
)
);
Where in this example you can copy the single.php
from your theme into an amp
directory inside your theme and this is the template that will be served when accessing the AMP version of a post. If you won’t want to copy you can instead (which I recommend) just create an amp/single.php
file and which contains:
<?php require get_template_directory() . '/single.php';
You can then use the exact same code in AMP and non-AMP, with perhaps some is_amp_endpoint()
calls sprinkled throughout to switch between AMP and non-AMP content. Note that it will try to use your main stylesheet, so if it it is larger than 50KB then it will get skipped.
Any testing you can do with this would be very helpful, as anything you identify could be something that needs to be fixed in 0.7.