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()
Code language: JavaScript (javascript)

4 reactions on »Get post type in block editor«

Leave a Reply

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