WordPress / developer-blog-content

In this GitHub space, WordPress team coordinate content to be published on the Developer Blog. Discussion and montly meetings (first Thu) in WP Slack #core-dev-blog
36 stars 2 forks source link

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

Closed bph closed 3 months ago

bph commented 5 months ago

Discussed in https://github.com/WordPress/developer-blog-content/discussions/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 commented 4 months ago

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

justintadlock commented 3 months ago

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.