I have my web page full on AMP using too the oficial plugin. I use templates for my content, the template is used everytime someone makes a post. All the page is in AMP but if I want that just one template just do not load in AMP, how can I make that happen? I tried using functions.php with no success
Asked
Active
Viewed 30 times
1 Answers
0
You can achieve that by using amp_is_request
in your template.
if ( function_exists( 'amp_is_request' ) && amp_is_request() ) {
/* AMP Request */
} else {
/* non AMP Request */
}
Otherwise you can use amp_skip_post
filter in your functions.php:
add_action(
'wp',
function() {
$template_slug = get_page_template_slug($post_id);
if ( $template_slug == 'Your template slug' ) {
add_filter( 'amp_skip_post', '__return_true' );
}
}
);
Note that both solutions will load full page in non AMP mode. If you want to load one of components in non AMP you can try using Sanitizers but still, that page is going to be AMP. As far as I know you can't have mixed AMP and non AMP content on one page at the same time, that violates the main idea of the AMP concept.

la_petite_kozel
- 826
- 5
- 26