Created
April 8, 2020 13:19
-
-
Save danielpost/efa6c86d51254c4f18f11febf6859bab to your computer and use it in GitHub Desktop.
WordPress Block Editor: Enable custom block only for certain post type(s)
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
if (namespace.postType === 'post-type-slug') { | |
registerBlockType(); | |
} |
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 | |
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