Make WordPress Core

Opened 4 years ago

Closed 21 months ago

#56847 closed defect (bug) (invalid)

Template parts and patterns

Reported by: matteomarchiori97 Owned by:
Priority: normal Milestone:
Component: Editor Version: 6.0.3
Severity: normal Keywords: close
Cc: Focuses: template

Description

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 (2)

#1 @poena
3 years ago

  • Component Themes → 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:
​https://make.wordpress.org/core/2023/07/14/configuring-development-mode-in-6-3/

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.
​https://make.wordpress.org/core/2024/03/06/new-feature-the-block-bindings-api/

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

#2 @poena
21 months ago

  • Milestone Awaiting Review
  • Resolution → invalid
  • Status new → closed

Hi
I am now continuing to close this ticket since there has been no new responses.
I hope the issues is resolved or clarified.

If there is any new information to help identify if this is a bug or a missing feature, the ticket can always be reopened.

Note: See TracTickets for help on using tickets.