Share your Block Bindings use cases and showcase #65961
Replies: 2 comments 1 reply
-
|
I would love to use block bindings to get meta into CPT templates. E.g. on a "Book" CPT, the author of the book is not the author of the WP post. I would love to use a block binding to get the custom meta for "book author" to display on the template. |
Beta Was this translation helpful? Give feedback.
-
|
I've been experimenting with "Twig templating block" which allows writing custom Twig/HTML template in block editor and to map available block bindings to it's template context variables. This allows using full templating language feature set as block bindings allow all regular PHP function return value types including collections and scalars. Block bindings seem a good fit for this use case, feeling like the "C" part in "MVC", written in code, and "V" is the part editable by user in the editor. It is also relatively safe with Example binding code & template: https://gist.github.com/jasalt/dc3d9b7704da431e184096595e0637ea Less polished Site Editor screenshot utilizing it from a site: Some example bindings for a video site allowing with some complex queries and processing with various 3rd party plugins, CPT's and such:
Looking to document it better during the autumn but the code is available for experimenting and it's quite succinct (~ 500LOC JS, ~ 400 LOC PHP). |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Use this conversation to share your current or desired use cases for Block Bindings 🙌
Please feel free to discuss limitations as well — all of this will help us shape the roadmap.
Beta Was this translation helpful? Give feedback.
All reactions