@guipex You are using AMP in transitional mode, so you can add CSS rules to your active themes style.css file. Also using the amp selector will ensure any CSS changes you make will only be valid on AMP URLs. You can see an example below:
html[amp] #page {
background-color: red;
}
Alternatively you can use an AMP CSS plugin or add CSS via functions.php using the amp_post_template_css action. Custom templates as you were doing are for AMP in reader mode only.
Right, but the problem is our CSS is bigger than 50kb because of plugins and theme, so my idea was “reset” and create a new css just for AMP. If i use amp_post_template_css it will be attached after inline css, that may be trimmed anyway right? What i can do in this case?
If it’s over 50kbs after the plugin performs you might be best off looking at which plugins are contributing to the excessive CSS error, and checking for any potential improvements or AMP replacements.
If you are looking to dequeue your themes CSS file you can use the following,
add_action( 'wp_enqueue_scripts', function() {
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
wp_dequeue_style( 'name-of-stylesheet' );
}
}, 1000 );
You can then use a similar function to enqueue your own stylesheet for your AMP URLs.
You’ll find a useful article on how the plugin handles CSS here, with links to Github issues on this subject.