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
- How to implement WordPress plugin update that modifies the database?
- wp.media update options and force render on uploader
- WordPress Plugin Development In MVC Architecture, How?
- Customize plugin update “new version is available” text
- “Donate to this plugin” for WordPress.org Plugin Authors
- How to handel multiple checkbox field in the admin settings page with Settings API
- Update Multiple Post Meta for the Same Post In One call?
- How to show custom message once on plugin activation?
- How do I configure WordPress to talk to a Microsoft SQL Server database?
- How to load a new template page according to a particular URL?
- How ( and mostly at what time ) can i prevent the alternate cron from running?
- What is the function to get plugin base url in multisite?
- PDF download – use wordpress functions
- API to filter new user registration $POST data?
- Set cookie then immediantly refresh the page
- How to add an attribute to the body tag with a plugin?
- Override the core function locate_template
- Changing image size to full size in Gutenberg’s block gallery
- Set user ID at time of wp_create_user
- How to Create a Custom Plugin Permalink
- How would I go about creating a user ranked post popularity page?
- link bbpress forum discussion to blogposts
- Re use the list table for a custom post type on another page
- Can we have an ‘Update metadata’ button in Image Gallery for all image instances?
- Customised plugin failed to install and activate
- Why is one phpunit test throwing an error on one class when all other classes are similar without error?
- How to get all posts belongs to a user between a certain date
- wp-load.php redeclares classes
- Plugin main file is constantly been fired on every website visit
- Where should custom post types be registered in a plugin?
- License validate function
- Change the number of plugins counted on wp-admin/plugins.php
- plugin uninstall function drop the tables, but shows errors on admin
- How to use template inside plugin shortcode with variables for big HTML code
- Way to send multiple values for column to MySQL?
- What’s the right way to implement functions in footer.php
- Do rewrites added with add_rewrite_rule() persist after plugin deletion?
- Display my plugins content based on a pages post_id
- How can i list random author?
- Our plugin tags not appearing in WordPress Plugin Repository
- Make get_permalink() work outside the Loop using filters
- How to get values from network settings panel?
- Pluging with content for a specific page or post
- Does WordPress do any internal caching if no plugin installed?
- WordPress Plugin- How to Insert Html&JS code in specific Page and specific Div
- Conditional delete metadata does not works
- Upload Image with a file URL and show dynamically on Frontend
- How can i solve php upgrade problem
- Error on plugin activation and creating new page
- Child theme modifications not showing up
- Why is my shortcode not working?
- wp_remote_post To external API multiple values with the same key
- Function settings_fields() not recognized (Uncaught Error: Call to undefined function settings_fields())
- what’s different between wpdb->prefix and table_prefix
- Can we rename a plugin directory for a already launched plugin?
- How to use custom footer template in a site-plugin?
- How to create a new database table whenever user changes options
- Am I correctly adding styles to plugin?
- How can I insert a record into a custom table from my custom form in my custom admin page?
- how to create table during plugin installation in side a class
- WP_Filesystem usage within a block of code
- Why function hooked using object are executing at all time?
- What is the Object for WP_Error Class?
- Ajax in Plugins: returns the whole page
- how to search through plugin in wordpress cimy-user-extra-fields?
- Any way to hook into WP after a page displays?
- Unable to pass arguments from plugin form to filter hook using ajax, the data is transferring via ajax but unable to pass as arguments in filter hooks
- How to update changes to multiple sites at the same time
- Why am I getting an error when requiring a file in my plugin?
- Running a function using Crown WordPress on one day a week, for example, Mondays of every week
- How to make a Template page to show the information of different things Shop and Product page?