Make WordPress Core

Opened 20 months ago

Last modified 2 months ago

#56847 new defect (bug)

Template parts and patterns

Reported by: matteomarchiori97's profile matteomarchiori97 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.0.3
Component: Editor Keywords: close
Focuses: template Cc:


Good day,
I am developing a WordPress theme (published, but still work in progress, W3CSSPress).
While I was trying to get a value from a function (in functions.php) into a component of the theme I noticed a strage behavior.

If I try to develop a normal template part in HTML and include in it a pattern which contains a dynamic content, then I move away the templates and reload the website (classic version of the theme) and then I move back the templates (block version of the theme) I find that the dynamic generated part got cached and is not generated again anymore.

Istead, if I avoid to use a template part and I put its content inside a pattern and I call it from the templates of the pages (like, front-page.html) the content gets dynamically regenerated correctly.

This could be a good behavior from a caching and performance point of view, but if a template part has got some dynamic content it should be regenerated.

Is it fixable in some way?

Change History (1)

#1 @poena
2 months ago

  • Component changed from Themes to Editor
  • Keywords close added

Hi @matteomarchiori97

It is not perfectly clear to me how to reproduce the issue. I did not understand from the description if the problem is with template parts not loading inside patterns, or, if it is a problem when changing a block theme to a classic theme and back.

To prevent caching of various Site Editing features, theme developers can set WP_DEVELOPMENT_MODE to theme:

Patterns can not contain truly dynamic content, because as soon as a pattern is placed in the content, it is no longer a pattern, just blocks, and whatever was generated by the PHP in the pattern is static, saved to the database with the rest of the content.

One way around this, is to use the new block bindings api, but it is only a partial solution.

I suggest closing this ticket because I believe it is a question about implementation, rather than a bug.

Note: See TracTickets for help on using tickets.