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 *

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)