I recently had the same issue. The workaround I used was to save the current post id as an attribute of the block:
const currentPostId = useSelect( ( select ) => {
return select( 'core/editor' ).getCurrentPostId();
}, [] );
useEffect( () => {
if ( currentPostId && currentPostId !== postId ) {
setAttributes( { postId: currentPostId } );
}
}, [ currentPostId ] );
Related Posts:
- Are there ways to make the Gutenberg editor wider? And the HTML-block higher?
- How to remove specific panels in the editor (Gutenberg) when editing a block (via right panel)?
- How to Disable auto id attributes in Heading tag?
- Is there any simple way to remove Gutenberg editor H1 H5 H6 and change the label for the rest H2 H3 H4?
- How `window.wp.oldEditor` is being set in the editor?
- Notion-like editing and layout with a convenient freeform collaborative editor in WordPress? [closed]
- How to Batch Convert Gutenberg post to Classic post?
- Layout Settings in the new Gutenberg editor
- How do I reinstate the “Add Block” feature that changes with the update?
- How can I reset/remove background colour from a block
- how to display gutenberg editor in a view
- How can i extend the existing Block Inspector Tabs in WordPress Gutenberg Editor?
- Embeds (YouTube, Spotify) Work Live but Won’t Load in Block Editor [closed]
- Where on Github, or elsewhere, can I find the code for core-blocks?
- Gutenberg translation is not working
- How to add javascript function in the “save()” of gutenberg block?
- Block Validation Fails: ‘
- Removing advanced section from brand new gutenberg block
- How to allow to add gradients to core/heading block?
- Add a hyperlink to a group block?
- Gutenberg: How to use RangeControl in the editor itself and make it work?
- How to change Block Controls Icon in Gutenberg?
- Adding content to Page settings rather than Block settings
- Detect if a block has been deleted
- Add multiple images to a custom block
- How do I disable the block marketplace for Editors?
- How to use __experimentalCaptureChildToolbar
- Why is wordpress suddenly stripping away all newline characters and how to disable this?
- Gutenberg RadioControl saving data but not not selecting radio
- Override RenderCallback from LatestPosts
- Gutenberg on block move
- Gutenberg template lock but add/delete blocks programmatically
- wp_get_global_settings is not updated on save_post hook
- How can I make Gutenberg block layout switchable without lost of current content?
- Change Image Size option in the settings in bulk
- code block does not show in excerpt
- Is it possibe to prepend “ with icons or text?
- If you have multiple dynamic blocks with a post loop on a page, how do you avoid duplicates from inside the render_callback function?
- How to create Gutenberg’s pattern category automatically with custom post taxonomy terms?
- How to Change the Gutenberg editor’s colors?
- Debugging Gutenberg block with the React Profiler (React Developer Tools)
- Modify core/image block by adding inner span to figcaption in save
- How to override a function in the wp_includes folder(block supports/colors.php)
- If is block name
- Is there a way to grab the current value of the editor in Gutenburg/Classic WordPress editor? (Not the saved value of the post!)
- ResizableBox component is not selectable in block editor
- Whitelist a single SVG for use in post_content
- Gutenberg block previews suddenly not working
- WordPress Gutenberg Signal on Block Alignment Change
- When to use block patterns over nested blocks?
- How to convert block to a list block in WordPress gutenberg editor?
- How to do store, retrieve and write attributes in the registerFormatType method in Guttenberg?
- How can I create more advanced layouts in Gutenberg block editor?
- How to replace the Gutenberg default block with a custom block?
- how to disable a button added by a plugin in gutenberg toolbar?
- Images are not shown in the post editor
- Updating failed message when a wp_insert_post function is hooked to save_post hook
- Gutenberg work with Bootstrap Shortcodes plugin
- Get post ancestors in the Block Editor
- How to disable blocks in Gutenberg editor for specific post type
- Possible to make the link autocompleter prioritize Tags before Posts?
- Prevent FormTokenField component to accept random entries
- How to move the customizations done in the Editor to my child theme?
- Unable to see the attributes for the custom block created
- How to condition appearance of a gutenberg block via wp_is_mobile
- Can I strip WordPress classes from blocks?
- How to list all registered blocks
- How to automatically reload style variant .json?
- Strange behavior of blocks in the editor
- Block editor not loading with rest api custom code
- In Full Site Editing, how do I get the templates I created to appear in the site editor when populating a new page?
- Dynamically add table of contents and add anchor based on heading innerHTML
- How to defer block.json scripts?
- Block validation: Block validation failed – Custom WordPress Gutenberg Block Fails In Editor when reloaded
- How can I prevent a user from selecting exactly one of two (not both or none) categories on a post?
- How to add a tooltip for MediaReplaceFlow from @wordpress/block-editor
- Star Rating block is not present from list of blocks or from / shortcut
- Gutenberg: is is possible to get the current permalink of the post?
- WordPress custom Block showing error in Posts editor but working in Pages editor
- Implementation of React-Datepicker component with Gutenberg in WordPress
- How disable settings on core/image (Gutenberg) block
- WP dynamic block – change content without saving
- Innerblocks isn’t adding new blocks when template changes
- What happened to the Menu Order option for posts (for ordering posts by Menu Order in Block Editor (Gutenberg)?
- How to prevent the core/group block from being ungrouped?
- Get FontSize from the InspectorControls Standard Control (typography.fontSize)
- Splide carousel block – innerBlocks not selectable after innerBlocks change
- How to create a custom block theme template based on a post category?
- Moving Post Title out of Block Editor
- Get the email of the author of the currently being edited post in Gutenberg frontend
- How to use get_option() in Gutenberg block editor to retrieve global settings?
- How to delete a page template created from the editor?
- Preventing Output of Layout Styles but Keep the Layout Classes in Core Block Editor
- How do I completely disable block editor?
- How to add script & PHP code to the section of a block editor theme template?
- Extending the Query Loop block
- Default Editor – columns not printing [closed]
- Page List Block doesn’t show all pages in edit
- Importing Google Fonts in Block Themes — Correct Way
- Gutenberg element Button How do I customize the hover and focus effects?