Title: Template Path Not Generating Properly
Last modified: September 16, 2019

---

# Template Path Not Generating Properly

 *  Resolved [steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/)
 * (@steve-from-breathe4u)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/)
 * Hi There,
    When I create a new block it doesn’t generate the template path and
   name for me to place and call the new template I’ve created. I’m using the pro
   version but because I’m working on a development site the site [path is in a 
   folder ie site.con/folder/). Any help you could give would be much appreciated.
   Thanks Steve

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/template-path-not-generating-properly/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/template-path-not-generating-properly/page/2/?output_format=md)

 *  Plugin Author [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/#post-11941254)
 * Hi [@steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/),
   
   Thanks for bringing this up.
 * Sorry to hear about the template path. Could you please help with a question 
   about this?
 * Is it:
 * 1. Not displaying the notice with the template path:
    [https://cldup.com/gLNZdqLF9m.png](https://cldup.com/gLNZdqLF9m.png)
 * 2. Not using the template for a block when one is added? For example, if the 
   template is at `<your-theme>/blocks/block-your-example-block.php`, is it not 
   rendering that template?
 * 3. Or both?
 * Thanks, Steve!
 *  Thread Starter [steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/)
 * (@steve-from-breathe4u)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/#post-11941327)
 * Hi Ryan. Thanks for your reply.
    It’s number 1. not displaying the path. when
   I create the fields and click publish. Thanks
 *  Plugin Author [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/#post-11941334)
 * Thanks, [@steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/)!
   Let me look at this more and get back to you.
 *  Thread Starter [steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/)
 * (@steve-from-breathe4u)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/#post-11941339)
 * OK. Thank for your help
 *  Plugin Author [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/#post-11941837)
 * Hi [@steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/),
   
   Hm, I’m not sure what could cause this.
 * Would you be able to place 2 lines of code in the `block-lab/php/post-types/class-
   block-post.php`, and let me know what the result is? Otherwise, setting an Xdebug
   breakpoint there would be great if you could.
 * 1. Above [this code](https://github.com/getblocklab/block-lab/blob/7893515b3dbef7c87502e30f4f03bfcc50b4f90b/php/post-types/class-block-post.php#L345):
 *     ```
       if ( ! $template ) {
       	add_meta_box(
       		'block_template',
       		__( 'Template', 'block-lab' ),
       		array( $this, 'render_template_meta_box' ),
       		$this->slug,
       		'normal',
       		'high'
       	);
       }
       ```
   
 * …could you please add this:
 *     ```
       var_dump( $template );
       wp_die();
       ```
   
 * …so all of the code should look like:
 *     ```
       var_dump( $template );
       wp_die();
       if ( ! $template ) {
       	add_meta_box(
       		'block_template',
       		__( 'Template', 'block-lab' ),
       		array( $this, 'render_template_meta_box' ),
       		$this->slug,
       		'normal',
       		'high'
       	);
       }
       ```
   
 * 2. Then, could you please click ‘Update’ in the block:
    [https://cldup.com/atxpbcYYxu.png](https://cldup.com/atxpbcYYxu.png)
 * 3. And if you’re comfortable with this, could you post in this support topic 
   what the result is? There should be debugging output. If there happens to be 
   sensitive information, feel free to not post that 🙂
 * Thanks, Steve!
 *  Thread Starter [steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/)
 * (@steve-from-breathe4u)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/#post-11942873)
 * Hi Ryan,
    changed the code but when I tried to edit my blocks I get a string 
   error on the page not the block edit screen: `string(105) "/home/*/public_html/
   macg-dev/wp-content/themes/*/blocks/*/block.php"` (asterisks replacing sensitive
   info).
 * Thanks Ryan
 *  Plugin Author [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/#post-11943060)
 * Hi [@steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/),
   
   Thanks, that’s interesting. It looks like it found a template for the block.
 * I’m not sure why it’s not displaying the template, like it does here:
    [https://cldup.com/17fOEkkTdS.png](https://cldup.com/17fOEkkTdS.png)
 * Is that string that it printed in your comment above a valid path to a file?
 * For example, in that `var_dump()` statement above, if you do:
 *     ```
       var_dump( file_exists( $template ) )
       ```
   
 * …does it print `true`?
 * Thanks for your patience, Steve!
    -  This reply was modified 6 years, 8 months ago by [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/).
 *  Thread Starter [steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/)
 * (@steve-from-breathe4u)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/#post-11943253)
 * Hi Ryan,
    That comment is the only thing on a completely blank page until I hit
   the back button in the browser. I tried putting the file exists code in the class-
   block-post.php but the back of the site shows a blank screen saying there’s an
   error. Hope this helps. Thanks Ryan
 *  Thread Starter [steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/)
 * (@steve-from-breathe4u)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/#post-11945184)
 * Hi Ryan,
    Thanks for all your help so far. Now when I create the fields for a
   new block, it gives me the same template path as one I already have created /
   wp-content/themes/kickstarter/blocks/block.php which is the default path. whatever
   I do it doesn’t want to change it. I’ve tried changing the field and the name
   but still the same path. The slug can be changed but has no effect on the template
   name. Don’t know if this helps at all Thanks
    -  This reply was modified 6 years, 8 months ago by [steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/).
 *  Plugin Author [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/#post-11947300)
 * Hi [@steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/),
   
   Thanks for your information, and sorry for the delay.
 * If it’s alright, I’ll look at this more tomorrow.
 *  Plugin Author [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/#post-11950205)
 * Hi [@steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/),
   
   Sorry for asking another question, but does the notice that references `blocks/
   block.php` look like:
 * 1. [https://cldup.com/H6CnlyirYP.png](https://cldup.com/H6CnlyirYP.png)
 * …or:
 * 2. [https://cldup.com/ne_V6WF13C.png](https://cldup.com/ne_V6WF13C.png)
 * Thanks, Steve!
 *  Plugin Author [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/#post-11950472)
 * **Possible Workaround**
 * Hi [@steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/),
   
   Also, maybe you saw this, but here’s a workaround that might help:
 * [https://wordpress.org/support/topic/template-not-found-9/#post-11916295](https://wordpress.org/support/topic/template-not-found-9/#post-11916295)
 * You could place that snippet in the root of your theme if you’d like, like in`
   <your-theme>/functions.php`.
 * It might help to force Block Lab to look in the theme for the template.
 *  Thread Starter [steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/)
 * (@steve-from-breathe4u)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/#post-11951184)
 * Hi Ryan,
    The path displays as option 1 under directly the main title. I already
   had the code you suggested in the functions file for a while but it doesn’t seem
   to make any difference if the code is used or not. Thanks for all your help. 
   Steve
 *  Plugin Author [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/#post-11954049)
 * Hi [@steve-from-breathe4u](https://wordpress.org/support/users/steve-from-breathe4u/),
   
   Thanks for helping.
 * It looks like [locate_template()](https://github.com/getblocklab/block-lab/blob/7893515b3dbef7c87502e30f4f03bfcc50b4f90b/php/post-types/class-block-post.php#L878)
   isn’t returning the template.
 * Maybe the `file_exists()` calls with the templates are mistakenly returning `
   false`.
 * You probably aren’t using a caching plugin, right? It sounds like this is on 
   a local.
 * Thanks for your patience.
 *  Plugin Author [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/#post-11954070)
 * This probably won’t fix it, but if you’re up for it, could you add this:
 *     ```
       clearstatcache();
       ```
   
 * at [this line](https://github.com/getblocklab/block-lab/blob/7893515b3dbef7c87502e30f4f03bfcc50b4f90b/php/post-types/class-block-post.php#L876)?
 * So all of the code would look like:
 *     ```
       clearstatcache();
       $locations = block_lab()->get_template_locations( $post->post_name, 'block' );
       $template  = block_lab()->locate_template( $locations, '', true );
       ```
   
 * Maybe the `file_exists()` calls are cached, even if there’s no caching plugin.
   But I’m not sure if that’ll help.

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/template-path-not-generating-properly/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/template-path-not-generating-properly/page/2/?output_format=md)

The topic ‘Template Path Not Generating Properly’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/block-lab_5c34e8.svg)
 * [Block Lab](https://wordpress.org/plugins/block-lab/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/block-lab/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/block-lab/)
 * [Active Topics](https://wordpress.org/support/plugin/block-lab/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/block-lab/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/block-lab/reviews/)

 * 18 replies
 * 2 participants
 * Last reply from: [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * Last activity: [6 years, 8 months ago](https://wordpress.org/support/topic/template-path-not-generating-properly/page/2/#post-11961547)
 * Status: resolved