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«

Mentions

  • Florian Brinkmann
  • Florian Brinkmann
  • Matthias Kittsteiner
  • Jesse

Leave a Reply

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

Your post must include a link to this post.

How does this work?
Write a response on your own website and include a link to this post. Then submit your response’s URL here. Your response may appear here after moderation. To update or remove it, edit or delete your original post and submit the same URL again. Learn more about Webmentions.