How to get post type from block editor DOM
-
I’m trying to unregister a plugin-generated (Gutenburg) editor block based on the post format. Right now, I’m just checking to see if the body tag has a class that follows the usual convention for custom post types, i.e.
post-type-typename
. But I’m wondering if there’s a better way to get it from the editor object.wp.domReady( function() { if(document.body.classList.contains('post-type-some-type')){ wp.blocks.unregisterBlockType( 'my-plugin/some-block' ); } if(document.body.classList.contains('post-type-some-other-type')){ wp.blocks.unregisterBlockType( 'my-plugin/some-other-block' ); } } );
Any thoughts would be appreciated. — E
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to get post type from block editor DOM’ is closed to new replies.