Title: Render Custom Gutenberg Template
Last modified: August 9, 2024

---

# Render Custom Gutenberg Template

 *  [Linus Benkner](https://wordpress.org/support/users/linusbenknerkk/)
 * (@linusbenknerkk)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/render-custom-gutenberg-template/)
 * Hi, I’m building a theme and need help with the following:
 * I have a custom post type that’s publicly queryable, so I have pages like this:
   `
   example.com/post-type/my-post`
 * I need automatically generated sub-pages on which I can show a form, like this:
   `
   example.com/post-type/my-post/form`
 * This is partially working now with a rewrite rule:
 *     ```wp-block-code
       add_rewrite_rule(	'^post-type/([^/]+)/form/?$',	'index.php?post_type=post-type&name=$matches[1]&form=1',	'top');
       ```
   
 * And I can intercept the request in the [`template_redirect`](https://developer.wordpress.org/reference/hooks/template_redirect/)
   hook:
 *     ```wp-block-code
       if(empty(get_query_var("form"))) {	return;}$postId = get_queried_object_id();
       ```
   
 * (I also registered the query vars using the [`query_vars`](https://developer.wordpress.org/reference/hooks/query_vars/)
   filter)
 * **Template:**
 * I created a custom template in Gutenberg and now I have the ID and the template
   available in my code:
 *     ```wp-block-code
       $templateId = 26;$templateName = "wp-custom-template-sample-form";
       ```
   
 * **How can I render this template / tell WordPress to do so?**
 * I tried the [`template_include`](https://developer.wordpress.org/reference/hooks/template_include/)
   hook, but it needs an absolute path to a php file which I don’t have, since it’s
   a Gutenberg template stored in the database.
 * Or do you have any other ideas on how to build this? Maybe the whole approach
   is wrong.

The topic ‘Render Custom Gutenberg Template’ is closed to new replies.

## Tags

 * [gutenberg](https://wordpress.org/support/topic-tag/gutenberg/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 0 replies
 * 2 participants
 * Last reply from: [Linus Benkner](https://wordpress.org/support/users/linusbenknerkk/)
 * Last activity: [1 year, 10 months ago](https://wordpress.org/support/topic/render-custom-gutenberg-template/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
