I was looking for the same thing.
This Answer by SkyShab did the trick. Posted below for convenience.
wp.data.dispatch('core/editor').editPost( {template: "template-name.php"} )
Related Posts:
- Gutenberg & Pre-formatted Templates: Core Block Attributes
- Gutenberg Editor – Template Doesn’t Match Error
- How does wordpress blocks?
- How to replace WordPress sidebars (widget areas) with Gutenberg
- How do you override Post template when using Query Loop block?
- How to custom page template for the Gutenberg editor
- Use PHP templates as blocks
- Can I add a default Block to my custom theme?
- Is there a way to create a block template that is not limited to a post type?
- Can you use block patterns in block templates or insert them programmatically?
- How to limit block activity (insertion/deletion) to inside of a Block Template on the Admin Screen?
- templates page not showing on gutenberg editor
- Category theme template becomes default template for child theme
- Adding new Template Parts in the Block Editor when using Classic Themes
- How to change the default registration email ? (plugin and/or non-plugin)
- Any advantage to using get_header() over include(‘header.php’)?
- What’s the purpose of the paged.php file?
- How to find the posts page (home page) programatically
- How to check if a shortcode exists?
- What is the link to my default “archive” page?
- Customizing get_the_excerpt() to specific length and “Read More” output.
- How do you check if a WordPress template file exist?
- Load entire NextGEN gallery from single thumbnail?
- stop blog page from using index.php?
- How to hide/redirect the author page
- Restrict a search to a custom post type
- How did you incorporate WooCommerce in your own WordPress theme?
- Change site template from php
- Show template loaded
- Display HTML only if Custom Field has a Value
- Get templated page/post content via the WordPress API
- Force all images to full size in page template
- Login WordPress website using wp-rest api
- Turning on the 404 page on localhost
- how to create template path for external (include) .js file
- Global variable set in the template’s header.php is unable to echo in footer.php
- How to Increment ID value within ACF Repeater Field Loop
- When a link doesn’t exist, how to tell WordPress what to do? (404 Error Page)
- WordPress Schema.org Markup. What value does it add?
- Stylesheet comment header: Which header names are mandatory? [duplicate]
- How to add posts list to a page template?
- home.php not loading
- get_search_link() redirects to 404 template page
- How to get the most recent modified date of anything in the footer of my site?
- New custom nev not working [closed]
- How do I insert JS tracking code to a page with the WP editor?
- LaTeX for WordPress strips codes in loop
- How to remove the Template drop down, but keep Parent and Order
- Search results when none found – stay on page they were on
- Include Lumen/Laravel app in custom WordPress template
- Rewrite Rules to custom template
- How to convert the WordPress meta box Page Attributes->Page Template dropdown to radio buttons?
- Unable to display pagination links on custom category template
- Best practice to update the file header.php
- page-{slug}.php vs. template-{slug}.php
- Understanding the Template hierarchy
- Override Dokan Includes File in Child Theme
- wp_enqueue_style and different styles for blog template
- Can I have both front-page.php and index.php?
- How is WooCommerce cart.php template supposed to be used?
- Two exact templates, sidebar showing in one but not the other
- get_header(), get_footer() from plugin template
- Problem creating a custom category page with pagination
- If Posted After Date
- how can I add a “read more” tag directly in the template?
- Update template without undoing all my edits?
- How to get and set the post tag value within WP Query from URL?
- Is it possible to access plugin data from a custom feed template?
- How can I get all archive-URLs to use the same template?
- How to use a template file to show all post having same metakey
- Automate configuration after new/hosted installation
- Modify just ONE page based on a template
- which template does wp_ tag_ cloud point to?
- Pagination problem (plugin wp-pagenavi) with a custom post type?
- Add an anchor link to a ‘plain’ HTML file, without over-writing the entire site?
- How to Modify WP_Includes/blocks/latest_posts.php
- Template part including not working
- Parent/Child themes – both CSS files loaded
- front-page.php includes a placeholder text field. How to get rid of it?
- Display a custom 404 page without a redirect
- Template and URL parameter problem
- get_users by role returns all users
- Validating Error with submit button
- How can I alter a post?
- What is the purpose of the $before and $after arguments on the the_title() function?
- Remove ” Browse Category : ” from Archive title
- When to use content-pagename.php?
- Using external file with WP_USE_THEMES set to false causing 404
- Current URL path variable
- How to install a wordpress website template on an existing website?
- Why is my no-results.php template moving my sidebar and footer into the main container?
- Given a page ID, how to display entire page (header/content/footer/sidebars) from a plugin hook
- Any way to insert text on page from a query results?
- Show page title just from the first child-page in template
- How to know which page/file WordPress is expecting?
- AJAX requests within templates
- Page.php vs Single.php
- Dynamic header and footer template inclusion: footer script not included
- How to create a template for a post in Query Loop block?
- How to edit templates created in the block editor in code / template files not updating