Skip to content

Instantly share code, notes, and snippets.

@danielpost
Created April 8, 2020 13:19
Show Gist options
  • Save danielpost/efa6c86d51254c4f18f11febf6859bab to your computer and use it in GitHub Desktop.
Save danielpost/efa6c86d51254c4f18f11febf6859bab to your computer and use it in GitHub Desktop.
WordPress Block Editor: Enable custom block only for certain post type(s)
if (namespace.postType === 'post-type-slug') {
registerBlockType();
}
<?php
wp_localize_script('script-handle', 'namespace', [
'postType' => get_post_type()
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment