That’s not how templates work.
A template is the initial block layout, a starting point.
Changing the template won’t do anything because the original template was used to create blocks and those blocks have already been created. Think about it, if it worked the way you thought it did, adding or removing from the template would erase all the content, and your content would be erased when the post loads.
What you’ve done is attempted to create a custom block appender, so instead of reinventing that feature you should instead use the block appender props and APIs. Templates are not appropriate for what you’re trying to do.
TLDR: If you want a custom block appender/inserter, use a custom block inserter/appender, don’t try to make templates dynamic, they aren’t and can’t be made dynamic, that’s not how templates work.
Related Posts:
- Passing select control value to block
- Passing RichText attributes to function onChange
- How do I store information in a dynamic block in WordPress?
- How to create custom embed block in gutenberg wordpress
- How to use get_theme_mod in gutenberg editor wordpress?
- How to add Internationalization in WordPress using Javascript/React?
- how to disable blockrenderAppender inside all Innerblocks?
- WordPress Gutenberg react make import of __experimentalUseInnerBlocksProps which is no more experimetal
- Using SVN to upload plugin created with gutenberg blocks
- How to add custom table style for table block in gutenberg editor
- Gutenberg Block Style CSS Class Is Not Applying on Backend
- Why is the ‘Gutenberg’ Plugin generating an ‘Inconsistent File Permissions’ error when other Plugins, with the same permissions, do not?
- Set Multiple Meta Values as an Array Using dispatch( ‘core/editor’ ).editPost() Call in Gutenberg/JS
- Use a custom block in another block
- Gutenberg default attributes are empty when accessing in edit
- Set Button in PluginDocumentSettingPanel Content (WordPress Gutenberg)
- Has blocks gutenberg block multiples registers type in my Plugin
- Fixed: Console.log twice in the edit function
- How to resolve warning for `unstableOnSplit` prop on a DOM element in block editor
- Block content rendering on the top just below body tag
- Gutenberg: Dynamic Block – Show saved data in the editor
- Create plugin with multiple blocks
- How do I set register_meta for a specific CPT?
- How do I save meta key value in the save function?
- Update Content for a Custom Block Toolbar Button
- Wrong block appender button showing
- How to get custom setting from get_option and pass it in getEntityRecords in gutenberg block?
- Vanilla javascript in custom gutenberg block not working
- WordPress custom block: Link saved in database not retrieved when editing post
- Why is my Gutenberg block not saving and rendering the chessboard?
- How can we extent core/group or cover block?
- How to change the version of block.js and plugin to the same of Package.json?
- How do I apply different block supports to different parts of my custom block?
- Custom Gutenberg blocks not showing in WP editor
- Pass PHP variable to javascript
- Namespaces in WordPress – How do I initiate the main class?
- wordpress get meta value by meta key
- How to create gutenberg block using REST API independently or as headless way?
- What areas to Unit test while building a plugin?
- Errors while using ajax from external wordpress page
- Pass A Value From Outside To A Plugin Variable
- shortcode doesn’t work
- How to handle autoloading with composer by keeping the WordPress naming conventions?
- Current user in plugin returns NULL
- What are the benefit in adding hook in the init() hook?
- How can I implement a notification system in wordpress?
- Minimum PHP Required for WordPress
- load_theme_textdomain path
- Building an email signup form. Where should the information be saved in the DB?
- Create entire wordpress as a github repositery?
- Conditional attributes and logic per product category
- Why Is This Code Causing The Admin Bar to Disappear?
- Displaying Custom Sidebar Without Modifying Theme’s Core File?
- Count posts by type including drafts and pending posts
- Redirect to another page using contact form 7? [closed]
- Separate database for a wordpress plugin
- WordPress Multisite: Programmatically Activate / Deactivate a Plugin of a Specific Blog
- remove all submenus from plugin
- Hook for page Request?
- composer not working on my plugin when i upload it to my website
- What is the WordPress approach to custom data?
- WordPress Fatal Errors [closed]
- How to render a template file using shortcode inside a plugin
- How to rewrite URL and get the values?
- Delete data from custom table when deleting a post
- Disable plugin visibility at the plugin directory
- Plugin is creating posts twice
- How to deactivate my plugin upon deactivation of NextGen
- Widgets are not displaying in the admin panel
- How to overwrite the category template in a plugin
- Content-Security-Policy implementation with WordPress W3Total Cache plugin installed
- function post to trash problem
- How to call function in WordPress on button click?
- How can I see $post object in frontend from functions.php?
- Move plugin pages from dashboard to front-end
- Allow members to create groups on my site
- WordPress UPDATE queries on MySQL database stuck
- Get post content inside plugin class method
- Ubermenu 3 Nav Bar Customization
- Where do the section input fields values are stored in database
- View more posts of a sub-category
- Update Plugin Without Overwriting Custom Settings
- How to customize ‘recurrance’ of’ wp_schedule_event’?
- Create Array from data in the OPTIONS table
- How to create and use Custom hooks
- Custom Function for SEO by Yoast plugin
- Call current post parameters inside a plugin
- Custom feed parameters / Template overriding
- wordpress select multiple options and illegal string offset ‘timeslot’ [closed]
- Creating Event Builder Plugin [closed]
- Hook for single product thumbnail
- Deprecated error notice
- Admin access to WordPress site with installing plugin
- Custom gutenberg block image preview not working
- Custom URL image is not zooming
- The Admin page isn’t showing in the sidebar of the dashboard
- Why is my activator class adding the files/running the actions I add?
- When to store store plugin options as a single database record?
- WordPress hack code issue, help required
- Trying to Find the PHP File/Function that Handles a Specific Form Action URL