Get post type in block editor

If you need to distinguish between post types in a block editor script, you can use the following code to get the post type:

wp.data.select('core/editor').getCurrentPostType()

Related posts

Leave a Comment

Your email address will not be published. Required fields are marked *