You can’t use block templates this way. They are used only by Gutenberg on client side (JavaScript) when new post content is created. In your case you are creating page on server side (PHP). However you can create pages with initial block structure. Create new page manually and save it without adding any content (there will be only empty block structure as defined by your block template). Then get it’s post_content value either from database using some DB client, or read and print it in some temporary PHP function. But you must get value exactly as stored in database. Use this text as string value for post_content in your page creation code.
This way you will have new page created with initial content matching your block template. Don’t forget to change value if you change template structure.
Related Posts:
- Proper, exhaustive documentation for wp.editor etc
- Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
- Add colors to existing color palette without replacing it
- Can you filter posts by meta key with the getEntitityRecords selector?
- WP Gutenberg custom block – generate theme colors from SASS and use them in the inspector and php callback
- Can I customize any WordPress parent block-based theme template files by child theme like a parent classic theme?
- How to support Lazy Loading Assets in a WordPress Theme?
- WordPress Gutenberg Theme: Structure, Hierarchy and Custom Templates
- Gutenberg Reusable Block as part of WordPress Theme page
- Custom button block doesn’t work
- How to float an image in Gutenberg
- Gutenberg – editor-font-sizes in functions not working
- Can’t select my block by clicking on it
- Which file handles the block latest posts, I want to examine excerpt handling
- create-guten-block in wordpress theme?
- What VSCode extensions are there for working with block themes? [closed]
- What is the “correct” way to add hooks or similar PHP behavior to a blocktheme?
- Not able to select width of blocks inside of cover block
- How to check if a WordPress core block is active in sidebar
- gutenberg add classes to list items
- How do you replace content generated by custom fields with custom blocks in Block Editor?
- Custom Blocks as part of a theme
- How to wrap all titles generated by Gutenberg “Heading” block with tag
- How to add InnerBlock multiple times in the same block
- Moving post title down the page / Removing a block from a post
- HTML block gutenberg templates
- Gutenberg theme development: how to add “headers” option under styles > colors > elements?
- Change default rel attributes for Image Block & Button Block
- How to update mark-up of a gallery block in a custom theme?
- Auto focus RichText field
- How to create nested array attribute
- Show popover with url and option to open in new window
- How to Modify WP_Includes/blocks/latest_posts.php
- How to render block editor in wp-admin custom pages programmatically
- Social-Link block not loading html on page with custom theme
- How to diagnose wp-env environment problem
- Attribute form NumberControl doesn’t update when I update page before it lose its focus
- WP Gutenberg custom block – generate theme colors from SASS and use them in the inspector and php callback
- Posts Page shows Classic Editor interface not Gutenberg
- How can I include custom Gutenberg Blocks in a theme?
- Block validation failed for `core/pullquote` after adding theme support for editor-color-palette
- Is there a way to add classes to a page when using a Gutenberg reusable block as page layout?
- Correct way to make a custom block theme responsive
- Multiple content areas with Gutenberg – Transparent areas mid content
- Insert gutenberg blocks into template
- Template for posts of category in block theme?
- Can’t select my block by clicking on it on apiVersion – but using blockProps
- How can I use pre declared blocks in a php file?
- Is there any filter or action hook to remove layout classes from appearing in my templates?
- Full site editing templates folder vs block-templates
- How to set the margin on an innerBlock in a block variation?
- Align images to the left of the content
- Image and font support missing in editor when deploying theme remotely
- Why is my Toggle field not showing in Gutenberg?
- When trying to run build script with gutenberg (with SVG import) – Error: Plugin name should be specified
- Block to show posts from same category
- Unwanted spacing for cover block
- Activate Gutenberg group block for theme
- How can a theme define which settings for blocks are available in the block editor?
- How to add multiple custom blocks in custom WordPress theme using create-block?
- How to create a template for a post in Query Loop block?
- WordPress 6.4.2 – can’t load editor style css using ‘after_setup_theme’ or ‘admin_init’ actions
- How to add group-row to InnerBlock template?
- Disable interactivity for core navigation
- Full Site Editing, Block Theme, Gutenberg, Site Editor
- FSE Change Post Template to Something Other Than a List
- How To extend WP_Customize_Control
- Removing all classes from nav_menu except current-menu-item and current-menu-parent
- Can’t edit style.css in subdirectory of my theme?
- Best practice for including plugins as part of a theme?
- customizing the_password_form filter
- Whats the safest way to output custom JavaScript and Css code entered by the admin in the Theme Settings?
- WordPress 404 page returning with default in IIS7
- searchform.php override not working
- Load child template based on parent
- Timber: Get single image from media library with all attributes
- page.php dependent sites are not working in custom woocommerce theme
- How can I override a require() used in functions.php of parent theme to my child theme
- Can I use WooCommerce in a headless CMS setup?
- How to transfer one domain to another domain without losing theme options (customizer)?
- Do I need to include a textdomain if my theme doesn’t support translation?
- adding class to excerpt
- Avada Child Theme Development
- Using the media library for theme customization
- Never actually adding the action? Or do I have to call the action?
- WordPress 6.x / PHP 8.x deprecated warnings in development environment
- Importing sass into underscores theme
- How can I fix my theme header for my CSS stylesheet?
- Alternative solution for script_loader_tag?
- How to transfer all posts, pages and media
- WordPress Customizer Help with FontAwesome Icon
- Correct (and secure) way to escape url when using href attribute
- Creating a Playlist of Widgets
- Loop through all posts, show attachment if there
- Confused on loading page content
- Problem dynamically generating an all purpose title tag
- why my WordPress theme doesn’t support shortcode? [closed]
- I’m new in developing responsive WordPress Theme, so which framework to use or work from scratch? [closed]
- What is the point of using archive.php instead of index.php?
- Querying by post category slug with core/query block markup