Skip to content

Instantly share code, notes, and snippets.

@westonruter
Created April 15, 2019 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/c9c203d6b938aa2e928fca8369706149 to your computer and use it in GitHub Desktop.
Save westonruter/c9c203d6b938aa2e928fca8369706149 to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: Try Disabling AMP by Default for a Custom Post Type
*/
namespace Try_Disabling_AMP_By_Default;
const POST_TYPE = 'book';
add_action(
'init',
function() {
register_post_type(
POST_TYPE,
[
'label' => 'Book',
'public' => true,
]
);
}
);
add_filter(
'amp_post_status_default_enabled',
function( $default, $post ) {
if ( POST_TYPE === $post->post_type ) {
$default = false;
}
return $default;
},
10,
2
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment