1

I have a modified Bedrock installation that moves the theme folder outside of the wp-content folder (and the normal app folder for Bedrock). In this setup, the app folder has a data folder that is the new wp-content and outside of it I have the plugins, mu-plugins and themes. This setup has worked for normal themes, but with an FSE theme, the template directory is not working.

Normally within the theme folder, you can have a templates folder or block-templates folder (the last one will is deprecated, but still works). When I open the editor, I get a message that the front page template is not found. But if I add that using the gutenberg plugin, it reveals the actual problem (shown in the image below). For some reason the name of the template is the full path of the repo. On my laptop, the repo is called wp so the web is the web root folder.

If I rename the templates folder to block-templates it seems to work fine, but I do not want to do that since that one will be depricated (and I cannot influence Twenty Twenty-Three). Is there a filter or setting that I am missing?

Issue where templates are named the complete path to the file, like wp/web/app/themes/twentytwentythree/templates/single

2
  • what's the filters/mechanism you used to create this setup that you're now trying to fix? It's hard to describe what modifications are needed without seeing what needs modifying in code, a prose description can be difficult to parse and only goes part of the way
    – Tom J Nowell
    Commented Feb 17, 2023 at 15:14
  • @TomJNowell, I'll leave the answer in a sec. I found it after some more testing. It had to do with the location I stored it on my laptop
    – Bas
    Commented Feb 17, 2023 at 15:33

1 Answer 1

1

After some more checking, I found the issue. The repo I was setting up, was a template that will be used by other sites, so I saved it in a folder called templates (Full path: /Users/bas/git/work/templates/wp). In the wp-includes/block-template-utils.php the name/slug of the template is decided with the following code.

$template_slug = substr(
  $template_file,
  // Starting position of slug.
  strpos($template_file, $template_base_path . DIRECTORY_SEPARATOR) + 1 + strlen($template_base_path),
  // Subtract ending '.html'.
  -5
);

$template_base_path is templates in the Twenty-TwentyThree theme, so it split it on the first occurrence of templates which was a lot earlier in the string (see the full path). If I moved my repo to /Users/bas/git/work/template/wp it all works since the string is splitted correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.