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

What you *can* and *cannot* do with PHP in patterns #214

Closed
bph opened this issue Feb 1, 2024 Discussed in #210 · 2 comments
Closed

What you *can* and *cannot* do with PHP in patterns #214

bph opened this issue Feb 1, 2024 Discussed in #210 · 2 comments
Assignees

Comments

@bph
Copy link
Collaborator

bph commented Feb 1, 2024

Discussed in #210

Originally posted by justintadlock January 25, 2024
A solid tutorial covering what functions are available to you when building patterns. For example, did you know that patterns are executed on init, a time when most WP conditionals are not yet set?

Why use PHP? Internationalization, dynamic URLs for loading media, and more.

You can also do things like loops instead of printing the block markup for repeated sections of the pattern with the same content (for example, a Columns block with the same nested columns).

@justintadlock
Copy link

Drafting this here: https://docs.google.com/document/d/1TVSeEklV2StuUmwwIUu_1_SscQtc1XZ8jVMbltC05fM/edit?usp=sharing

@justintadlock
Copy link

justintadlock commented Mar 9, 2024

Because we needed pretty much the same doc for the Theme Handbook, I ended up porting this as an article that will live under the upcoming Patterns chapter: https://docs.google.com/document/d/1b4K4w1GyW09Z-yJpwAODT3mPqQCDAG3H7Xr3kgqyWyg/edit?usp=sharing

I feel like that's the best place for this at this time. We can always build on top of that documentation with a Dev Blog article in the future. But I feel like I've accomplished what I set out to do (create a resource for themers to learn how to use PHP in patterns), so I'm closing this for now.

If anyone wants to pick it up with a new angle, we can always reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants