WordPress 6.5 adds a new Block Binding API feature that lets you add real-time data to a page's module

As the block editor has evolved, the lack of good support for custom fields has been an issue. While custom fields are still commonly used in WordPress, they were placed at the bottom of the page in the block editor and were not well integrated. However, with the new Block Bindings API, this is all set to improve.

Image[1]-WordPress 6.5 adds a new Block Binding API feature that lets you add real-time data to a web page's modules-Photonflux.com | Professional WordPress Repair Service, Global Reach, Fast Response

What is the Block Binding API?

Imagine if you are building a WooCommerce store and designing the homepage with a block editor. You might use a special loop to display the most popular products, which involves a lot of different information, such as product descriptions, images, galleries, and add-to-cart buttons.

Currently, WooCommerce requires custom blocks to be made and managed separately for each type of message, which means a lot of duplicated work and technical burden. And, whenever the block editor is updated with a new design tool, the development team needs to update all the custom blocks to make sure they work properly. But wouldn't it be easier if they could just use regular blocks, like paragraphs, headings, or buttons, and tell WordPress to let those blocks display product information?

This is the goal of the Block Binding API, which is not limited to custom fields, but can help with all types of data, making it easier to manage data in the block editor, whether it's post and site information (such as author names or featured images) or keeping templates synchronizedfunctionalityStronger.

Can dynamic data save time and resources?

To get a deeper understanding of the Block Bindings API, I contacted the lead developer of the Pods framework and the core WordPress project Fields API The Fields API addresses the problem of how to avoid developers writing the same code over and over again.

Tools like Pods, Advanced Custom Fields (ACF), and others were created to solve this problem. They allow developers to create custom post types, set up pages and field inputs without having to rewrite the code every time.

Scott related his work to WooCommerce, mentioning that many of the contributors to the Block Bindings API have also contributed to WooCommerce. He explained that the new WooCommerce product editing pages are now made up of blocks, and that they're looking for a more unified approach to integrating these blocks, rather than using a different block for each feature.

Scott has been providing feedback to the API and making sure the Pods framework is compatible with WordPress 6.5 before it is released.

I also spoke to Iain Poulson, Product Manager at ACF, and asked if we'd see ACF custom fields bound to WordPress core blocks in the future via this API, and Iain said that the ACF team is looking closely at the API and exploring ways to make ACF fields bind to block attributes, and that they'd like to show a prototype soon.

Initially, plugins like Pods and ACF may support this API directly, but last-minute security reviews mean that plugins with specific integrations are required to work.

Iain told me this week that there is an update being merged into WordPress core that may affect the binding of ACF fields to blocks. They anticipate big changes to WordPress, the new connectivity interface and the ability to update values will be very important to ACF users and they will make sure they work with the WordPress core team to support these features.

It's exciting to see that major plugins are investing in this new API, but there's also a need to adjust our expectations of the API as it takes a while and a lot of testing to integrate into developer workflows.

Is this an API with no UI?

Although the Block Bindings API has been added to WordPress version 6.5, regular users have not yet seen the direct interface for this feature. This new feature is mainly for plugin and theme developers, allowing them to develop based on this new tool.

Currently in version 6.5, there are two ways to use block bindings, both of which require writing some code:

  1. You can follow the WordPress Developer BlogThe suggestion is to switch to "Code View" in the block editor and add the binding data directly in the HTML.
  2. Alternatively, you can use the Block Variations API to add a new core block variant, which contains the binding data. This requires you to add some JavaScript code to the theme or plugin. The benefit of this approach is that once it's set up, it will work properly in the content editor and the variants you create will show up as separate blocks in the block inserter.

Currently, this feature only supports the four most commonly used blocks: paragraphs, headings, buttons, and images. This already covers most use cases, although more blocks will be supported in the future. For end users, this means that blocks that utilize this API will be just as easy to use as the core blocks they're already used to.

The project tracker shows that the Block Bindings API interface, which requires no coding, will be available soon, and there are already some proof-of-concept examples. In this way, the WordPress core team can see how this functionality is used in practice before making more changes to the block editor, and it may also provide some inspiration to the plugin team.

If you're a regular user, you probably haven't seen any changes yet. But if you're a plugin or theme developer, now is a good time to get to know the Block Bindings API and explore how it can help you save development time.


Contact Us
Can't read the tutorial? Contact us for a free answer! Free help for personal, small business sites!
Customer Service
Customer Service
Tel: 020-2206-9892
QQ咨詢:1025174874
(iii) E-mail: info@361sale.com
Working hours: Monday to Friday, 9:30-18:30, holidays off
? Reprint statement
This article was written by Harry
THE END
If you like it, support it.
kudos0 share (joys, benefits, privileges etc) with others
commentaries sofa-buying

Please log in to post a comment

    No comments