A real-world use case: custom meta + block bindings + variations + usage in templates
justintadlock opened this issue ยท 8 comments
Discussed in #231
Originally posted by justintadlock March 1, 2024
In #222 and #225, I introduced the Block Bindings API. But I should stress that these were merely very basic introductory posts on a vast subject that will empower developers to do some really powerful things with WordPress 6.5+.
With the introduction out of the way, it's time to showcase what folks can really do with this API in more of a real-world use case. I still need to map out the full plan for this, but my general idea is this:
- Developer is building a site that is slightly more complex than a regular blog. Book review website?
- Requires custom post meta for data (e.g., rating, ISBN number, etc.).
- Uses a custom Editor Plugin to add fields for entering metadata in the post sidebar.
- Needs a custom post template for different structure.
- Needs a custom archive template with custom Query Loop variation.
- Uses the Block Bindings API to render post metadata.
- Needs the Block Variations API for inserting blocks that are bound to post meta.
- Could use some patterns for use in the theme and by the user with the Block Bindings already in place.
- It could also showcase Block Locking to control what the user can change.
Essentially, this post (maybe even series) could touch on a lot of features in WordPress and show how developers could bring them together from Point A to Point B.
I'm working on the code examples in this repo for the moment: https://github.com/justintadlock/tt4-book-reviews
I'm working on the draft for this here: https://docs.google.com/document/d/19ySkgbDNzHoHg0Ly1z1VKOFv21UByW06mu7M5TchAPA/edit?usp=sharing
I needed to split this into two separate posts to keep the word count at a reasonable length. The first part is now ready for review: https://docs.google.com/document/d/19ySkgbDNzHoHg0Ly1z1VKOFv21UByW06mu7M5TchAPA/edit?usp=sharing
Just completed the 1st review and added some suggestions. Great article! ๐
I'll take the 2nd review :-)
I made a few comments, but it's practically done. As always, great tutorial, @justintadlock
Social Copy:
Learn how to combine block bindings, custom fields, block variations, and custom editor controls in this tutorial on the Developer Blog:
Post scheduled for May 13 on socials.