Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: "Template part has been deleted or unavailable:header". #429

Closed
ashrudral opened this issue Jul 28, 2023 · 6 comments
Closed

Error: "Template part has been deleted or unavailable:header". #429

ashrudral opened this issue Jul 28, 2023 · 6 comments

Comments

@ashrudral
Copy link

I am still getting the issue of "Template part has been deleted or unavailable:header".
Objective: create child theme of blockbase and spectra.

Wordpress: I am on WP 6.2
create block theme version 1.13.1.
Screenshot 2023-07-28 163829

How to recreate the error:

  1. Install blockbase theme on fresh WP site version 6.2.2
  2. Install create block theme plugin
  3. create child them with only 1 word name for child theme.
  4. download child zip
  5. upload child theme zip
  6. activate theme
  7. Go to site, following error:
    "Template part has been deleted or unavailable:header".
    "Template part has been deleted or unavailable:footer".
    This error is there in many more places such as icons meta, post meta, etc.
@bystrzan
Copy link

bystrzan commented Aug 27, 2023

There's a problem with handling the template parts - You can easly fix it by adding to the frontpage.html "theme name / slug", so get header part will look like:

<!-- wp:template-part {"slug":"header","theme":"YOUR_THEME_SLUG","tagName":"header"} /-->

Ofcourse you should update it also in DB by switch to show code and replace exported - buggy version of those lines.

Same for any other template part. I found that this problem isn't always the problem with Create Theme Plugin, but mostly when theme has a name where 2 or more words, or / and template part has own pattern inside.

The above fix is quickfix / hotfix for developers that already creating the themes with this plugin.

@ashrudral
Copy link
Author

Just want to mention again that:

  1. I am using single word name. My child theme name: "Blockbasechild"
  2. The parent theme is Blockbase.

Thank you for your response. Indeed, It must be a pattern inside the parent theme causing error. The quick fox you provided, I don't fully understand where to insert that snippet?

Luckily, I was able to manually create a child theme by creating a style.css and function.php file in the child theme folder and it is working for me.

@bystrzan
Copy link

bystrzan commented Aug 28, 2023

@ashrudral

  1. So this is not a problem (theme name / slug)
  2. It doesn't matter what theme it is - the problem is that while exporting changes from DB to the theme frontpage.html the CBT plugin often miss some part of code that should be included to get global template parts to work.
  3. Steps to fix the problem (each time you export or save changes to the theme files):
  • A) Go to edit your Front Page in Editor and in the top right corner click 3 dots menu and click on "Code Editor".
  • B) Open frontpage.html in code editor on your computer and:
  • for A & B replace first and last lines - like here:

this:
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
with: ↓
<!-- wp:template-part {"slug":"header","theme":"blockbasechild","area":"header"} /-->

and this:
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->
with: ↓
<!-- wp:template-part {"slug":"footer","theme":"blockbasechild","area":"footer"} /-->

You can read more about this bug here:

@pbking
Copy link
Contributor

pbking commented Sep 20, 2023

This is the issue to watch. Rendering a template-part from a pattern doesn't work as it should unless you include the theme attribute, however including the theme attribute means that the theme HAS to be installed at the "top level" of the /theme folder which isn't always the case. Thus rendering correctly without the theme attribute is the fix to make. In the meantime I suggest avoid using template parts in patterns.

WordPress/gutenberg#53194

@t-hamano
Copy link
Contributor

t-hamano commented Jan 7, 2024

Now that WordPress/gutenberg#54595 has been merged, can we close this issue?

@mikachan
Copy link
Member

mikachan commented Jan 8, 2024

Now that WordPress/gutenberg#54595 has been merged, can we close this issue?

Yes, I think so! 🎉

@mikachan mikachan closed this as completed Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants