Created
April 15, 2019 23:07
-
-
Save westonruter/c9c203d6b938aa2e928fca8369706149 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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