@lowestofthekeys thanks for the topic! Under AMP > General, there is a Supported Templates section where you can select Posts as a content type to serve AMP by default (you can also choose to support all templates as AMP). That should enable the toggle on new posts.
Hi Renee,
I have that set already.
Currently AMP is set to “disabled” on any new posts. I’m wondering if there is a way to change it to “enabled” automatically anytime someone creates a new post.
@lowestofthekeys Are you perhaps looking for the amp_post_status_default_enabled filter?
You can disable AMP for new posts by default by adding this to your custom theme’s functions.php or a custom plugin:
add_filter( 'amp_post_status_default_enabled', '__return_false' );
If you want to default old posts to be disabled but default new posts (starting this year) to be enabled, this would be an option (untested):
add_filter(
'amp_post_status_default_enabled',
function ( $enabled, $post ) {
return get_post( $post )->post_date > '2020-01-01';
},
10,
2
);
Ha, that worked perfectly. I just tested this via functions.php and any time I generate a new post, the AMP option is enabled (the option is disabled on the older posts).
Thank you!