Documentation-Issue-Tracker
Documentation-Issue-Tracker copied to clipboard
Specify difference between Pattern and Template/Parts files in docs (i.e. PHP vs HTML)
Issue Description
The Patterns chapter does not clearly specify that, unlike template and template-parts files (HTML), pattern files in a theme are PHP files
URL of the Page with the Issue
https://developer.wordpress.org/themes/patterns/introduction-to-patterns/
Section of Page with the issue
Introduction to patterns
Why is this a problem?
The fact that patterns should be saved as /patterns/hero.php (php files) is briefly mentioned in the following chapter (Registering patterns) whereas all 'reusable component' files described in the structuring of a block theme up to this point are expressly referred to as being html files
Suggested Fix
Stress that, unlike the files that go inside /templates and /parts, pattern files are php files and to do so both in 'introduction to Patterns' and in 'Registering patterns'
Heads up @WordPress/docs-issues-coordinators, we have a new issue open. Time to use 'em labels.
We can add a Para like this to stress on these points,
-
Unlike template and template part files, which are written in .html, pattern files must use the .php extension (e.g., hero.php) and are stored in the /patterns directory. This is because patterns are registered via PHP and may include localization functions or dynamic logic. It's important to follow this convention when organizing your block theme to ensure patterns are recognized and function properly.
-
Example Folder structure -:
my-theme/
├── templates/
│ └── index.html
├── parts/
│ └── header.html
└── patterns/
└── hero.php
That would be clear. I’d stress that is probably important to specify tgat (or provide a link to this point) in both ‘registering patterns’ and ‘introduction to patterns’ since one can’t give for granted a ‘linear’ fruition of the docs