Description
I regularly use select('core/editor').getCurrentPostType() to read the type of post currently being edited in the block editor. I use this to tailor the editor and allow certain blocks for ease of editing. This works wonderfully on post, page, and any custom post type. But, this does not work in the Site Editor when editing a Template or Template Part.
I'm eager to find out if there is any way to identify exactly which Template or Template Part is currently being edited.
Without that data, I can't streamline the editor to, e.g., provide a footer-specific block in the "Footer" Template Part only. Without this, the otherwise excellent #42729 isn't as useful as custom post types are to let us simplify the experience for content editors.
Step-by-step reproduction instructions
The following examples use WordPress@6.0.2 with the TwentyTwentyTwo theme active. I have tried with and without Gutenberg@14.1.1 active, and the results are the same.
Baseline example on a post (i.e. working data stores providing good data)
- Open a post in the block editor
- In the browser's console, run
wp.data.select('core/editor').getCurrentPostType()
✅ See "post" returned, which is what I expect
- Run
wp.data.select('core/editor').getCurrentPostId()
✅ See 837 (or whatever ID you have) returned, which is what I expect
Non-working example in the Site Editor
- Open the Site Editor through
Appearance > Editor
- Edit the site's
Home template
- In the browser's console, run
wp.data.select('core/editor').getCurrentPostType()
❌ See null returned, which is surprising. I expect to see wp_template (or wp_template_part when editing a Template Part).
- In the browser's console, run
wp.data.select('core/editor').getCurrentPostId()
❌ See null returned, which is surprising. I expect to see twentytwentytwo//home (or twentytwentytwo//header when editing the Header Template Part).
Screenshots, screen recording, code snippet
No response
Environment info
- WordPress@6.0.2
- TwentyTwentyTwo theme active
- Gutenberg@14.1.1 active (or non-active, doesn't matter)
- Firefox@104.0.1
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Description
I regularly use
select('core/editor').getCurrentPostType()to read the type of post currently being edited in the block editor. I use this to tailor the editor and allow certain blocks for ease of editing. This works wonderfully onpost,page, and any custom post type. But, this does not work in the Site Editor when editing a Template or Template Part.I'm eager to find out if there is any way to identify exactly which Template or Template Part is currently being edited.
Without that data, I can't streamline the editor to, e.g., provide a footer-specific block in the "Footer" Template Part only. Without this, the otherwise excellent #42729 isn't as useful as custom post types are to let us simplify the experience for content editors.
Step-by-step reproduction instructions
The following examples use WordPress@6.0.2 with the TwentyTwentyTwo theme active. I have tried with and without Gutenberg@14.1.1 active, and the results are the same.
Baseline example on a
post(i.e. working data stores providing good data)wp.data.select('core/editor').getCurrentPostType()✅ See
"post"returned, which is what I expectwp.data.select('core/editor').getCurrentPostId()✅ See
837(or whatever ID you have) returned, which is what I expectNon-working example in the Site Editor
Appearance>EditorHometemplatewp.data.select('core/editor').getCurrentPostType()❌ See
nullreturned, which is surprising. I expect to seewp_template(orwp_template_partwhen editing a Template Part).wp.data.select('core/editor').getCurrentPostId()❌ See
nullreturned, which is surprising. I expect to seetwentytwentytwo//home(ortwentytwentytwo//headerwhen editing the Header Template Part).Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes