The Block Bindings API connects dynamic WordPress data to supported block attributes. In WordPress 6.5 and later, a block can keep ordinary fallback content while its metadata.bindings declaration asks a registered source for the value used at render time. WordPress 6.7 adds JavaScript registration for editor-side reading, saving and permission checks.
Antihost offers managed WordPress hosting with free migration, one-click staging and a 14-day free trial.
What the Block Bindings API does
Block Bindings separates a block’s presentation from the data displayed in one of its attributes. A paragraph, heading, button or image remains a normal block, but a binding tells WordPress to obtain one attribute from a data source. The rendered value is then reflected in the HTML sent to the browser.
As an Amazon Associate I earn from qualifying purchases.
The block still has its ordinary attribute value. That value acts as a fallback when the binding cannot return a replacement. This makes a bound block safer than replacing the block with custom markup: existing content remains meaningful if a field is empty, unavailable or not yet supported.
The API is available in WordPress 6.5 and above. The WordPress Developer Resources handbook states: “Block Bindings API is only available for WordPress 6.5 and above.” Use WordPress 6.7 or newer when you also need JavaScript registration in the editor.
#1 Best Overall
- [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
- [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
- [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
- [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
- [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
How a binding is resolved
- A block attribute is selected. For example, the
contentattribute of a paragraph or theurlattribute of a button. - The block metadata names a source. The source identifier is stored under
metadata.bindings. - WordPress invokes the source. A built-in source or your PHP callback receives the binding arguments, the block instance and the attribute name.
- The source returns a value. That value replaces the ordinary attribute value for rendering. Returning
nullorfalselets the implementation choose the appropriate no-value behavior. - The block renders normally. The final HTML uses the resolved value, while the original fallback remains in the block comment and can be used when no bound value is available.
This model is useful for product cards, directory listings, event details and other layouts where the design should be reusable but the displayed data belongs to the current post.
Supported blocks and attributes
Bindings are not automatically available on every block attribute. The handbook’s default compatibility list is:
| Block | Bindable attributes |
|---|---|
core/image |
id, url, title, alt, caption |
core/heading |
content |
core/paragraph |
content |
core/button |
url, text, linkTarget, rel |
core/navigation-link |
url |
core/navigation-submenu |
url |
core/post-date |
datetime |
Compatibility can expand in later WordPress releases. Check the handbook for the release you support before designing a binding around an attribute that is not listed. Compatibility is attribute-specific: support for one attribute on a block does not imply support for every other attribute on that block.
Choose a source before writing code
Use a built-in source when possible
WordPress includes core/post-meta, core/post-data, core/term-data and core/pattern-overrides. A built-in source has less code and fewer moving parts than a custom callback, so start there when its data model matches your requirement.
Register a custom source for transformed or external data
Use a custom source when the value needs a custom lookup, transformation, fallback policy or permission rule. Your callback can read post meta, query another WordPress object or derive a value from the current post context.
| Requirement | Best fit | Main trade-off |
|---|---|---|
| Read a standard post, term or pattern value | Built-in source | Limited to the data and behavior exposed by core |
| Read a custom field with a simple lookup | Custom PHP source | Requires registration and callback maintenance |
| Show a value only on the front end | PHP registration and rendering | No editor-side editing of the bound value |
| Let editors change the underlying value in the editor | PHP plus JavaScript registration | Requires save logic and an explicit permission decision |
| Use data belonging to the current post | Source requesting postId context |
Callback must handle missing or invalid context |
A practical post-meta binding workflow
For a simple rating, subtitle or directory field, begin by deciding which value is authoritative. The post-meta field should be the source of truth; the paragraph, heading or button supplies the visual presentation and a safe fallback. This keeps content storage separate from layout and lets the same block structure be reused across posts.
- Choose a key. Use a normal key such as
rating. An underscore-prefixed key is protected and cannot be used with Block Bindings. - Expose the key to REST. Register the meta field with
show_in_rest=truebefore relying on the core post-meta source. - Select a compatible attribute. A paragraph or heading can bind its
content; a button can bind itstextorurl; an unsupported attribute will not resolve simply because the meta field exists. - Add the binding declaration. Put the source name and any field argument inside
metadata.bindings. - Keep default content. Write fallback text that still makes sense when a post has no value.
If the field is only displayed, a server-side source is sufficient. If an editor must change it from the block editor, plan the JavaScript registration and persistence path before presenting the block as editable.
Prerequisites for post-meta bindings
To bind a post-meta field through the core post-meta source, register the meta key with show_in_rest set to true. Protected keys beginning with an underscore cannot be used with Block Bindings.
Rank #2
- 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
- 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
- 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
- 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
- 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
- Run WordPress 6.5 or newer.
- Use a non-protected meta key, such as
rating, rather than an underscore-prefixed key. - Register the field with REST exposure enabled.
- Bind only to a compatible block attribute.
- Keep useful fallback content in the block.
If the value is intended to be edited by an editor, the source must also provide editor-side behavior in WordPress 6.7 or later. A read-only binding does not become editable merely because the post-meta field exists.
Register a custom source in PHP
Register sources during the init action. Source names use a namespace and slug separated by a slash. The function reference requires lowercase letters, numbers, dashes and a slash in the identifier.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstall<?php
add_action( 'init', function () {
register_block_bindings_source(
'my-plugin/product-rating',
array(
'label' => __( 'Product rating', 'my-plugin' ),
'get_value_callback' => function ( array $source_args, $block_instance, string $attribute_name ) {
$key = $source_args['key'] ?? '';
if ( ! $key ) {
return null;
}
return get_post_meta(
$block_instance->context['postId'],
$key,
true
);
},
'uses_context' => array( 'postId' ),
)
);
} );
What each registration field means
my-plugin/product-ratingis the source name that must later appear in block markup.labelis the human-readable name used by interfaces that expose the source.get_value_callbackreceives$source_args, the block instance and the attribute name. It returns the replacement value,nullorfalseaccording to the behavior you want.uses_contextrequests context keys from the block. Here,postIdlets the callback read metadata belonging to the current post.
Guard required arguments before querying. In the example, an absent key returns null instead of attempting an invalid lookup. A production callback should also account for a missing postId if the source can be invoked outside a normal post context.
Design the callback contract carefully
Treat the callback as a small contract between the block markup and the data layer. The args object is controlled by the binding declaration, so use clear argument names and document what each one selects. The callback receives the attribute name as well; this allows one source to distinguish whether it is supplying, for example, a paragraph’s content or a button’s url.
Validate the arguments before reading data. An empty key should not become a broad or accidental lookup. Likewise, do not assume that postId is present merely because uses_context requests it. The source may be encountered in a context where the expected post information is unavailable, and the fallback should remain usable.
Return a deliberate result for every supported case. A normal replacement value supplies the bound attribute; null or false can represent a no-value result according to the behavior you choose. The important point is to decide what an empty field should do instead of allowing an undefined condition to produce confusing output.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Attach the source to block markup
Put the binding under the block’s metadata object. The attribute name is the key, while source must exactly match the name registered in PHP. The optional args object is passed to the callback as $source_args.
<!-- wp:paragraph {
"metadata": {
"bindings": {
"content": {
"source": "my-plugin/product-rating",
"args": { "key": "rating" }
}
}
}
} -->
<p>Fallback text</p>
<!-- /wp:paragraph -->
In this example, the paragraph’s content is bound to the rating meta key. “Fallback text” remains the ordinary paragraph content. If the callback does not return a value, that fallback gives the block a usable default instead of leaving an unexplained empty region.
Rank #3
- [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
- [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
- [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
- [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
- [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
Binding several attributes
A block can have more than one binding when each attribute is compatible. Add another attribute key inside bindings, and point it to the same or a different source. Keep each source argument explicit so that a later reader can tell which field supplies each attribute. Verify every pair independently: one valid binding does not make an unsupported neighboring attribute valid.
Request post-aware context
Context is how a source knows which post, post type or related object is being rendered. In PHP, declare the required keys with uses_context. The callback then reads them from the block instance’s context. The official examples use postId for post-specific data; a source that needs the post type can request postType as well.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesRequest only the context keys the callback actually needs. A context-free source is simpler when its result depends solely on the arguments in the binding. A post-aware source is appropriate when the same block pattern should resolve differently for each post.
When editor code is present, declare the corresponding keys with JavaScript’s usesContext. Matching declarations let the server and editor resolve the same post-aware value instead of showing one value in the editor and another on the front end.
Add editor behavior in WordPress 6.7+
Server rendering and editor interaction are separate concerns. WordPress 6.7 adds JavaScript registration through registerBlockBindingsSource() from @wordpress/blocks.
import { registerBlockBindingsSource } from '@wordpress/blocks';
registerBlockBindingsSource( {
name: 'my-plugin/product-rating',
usesContext: [ 'postId' ],
getValues( { context, bindings } ) {
return {};
},
setValues( { dispatch, bindings } ) {
// Persist edits when the source is editable.
},
canUserEditValue() {
return false;
},
} );
getValues
getValues supplies values to the editor. Its callback receives editor context and binding information. Return the values required by the bound attributes, using the same source name and attribute mapping as the server implementation.
Free tools Windows power users keep installed
One-click scans. No signup required.
setValues
setValues persists an edit when the source is designed to be writable. The callback receives dispatch and binding information, so it can update the underlying post, meta field or other data store. Do not expose a write path unless the source can validate and save the incoming value correctly.
canUserEditValue
This function controls whether the user may edit the bound value. Returning false makes the binding read-only in the editor. A writable source should return an appropriate permission result and still enforce authorization in the persistence layer; hiding an editor control is not a substitute for server-side permission checks.
Rank #4
- Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
- Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
- All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
- Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
- Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
Keep names synchronized
When PHP and JavaScript implement the same source, their name and registered PHP identifier must match exactly: my-plugin/product-rating is different from a spelling or capitalization variant. Declare matching context keys on both sides so the server and editor resolve the same post-aware data.
Read-only versus editable bindings
| Model | Server code | Editor code | When to use it |
|---|---|---|---|
| Read-only | Required | Not required | The binding displays calculated or centrally managed data. |
| Editor-aware, still read-only | Required | getValues and canUserEditValue |
The editor should preview current data but never change it. |
| Editable | Required | getValues, setValues and permission logic |
Editors must update the underlying source from the block editor. |
Choose the smallest model that meets the requirement. Adding JavaScript registration solely to display a value increases the implementation surface without providing an editing benefit. Conversely, adding a setter without a clear permission decision can expose an editing path that the source was never designed to support.
Recommended Free Tools
Test the two data paths separately
Test front-end rendering and editor behavior as related but distinct paths. For rendering, use one post with the field populated and another where the field is absent. Confirm that the populated post receives the source value and that the empty case retains an intentional fallback. Also test a block with an invalid or missing argument so the callback’s guard is exercised.
For the editor, verify the current value returned by getValues, then test a user who should be able to edit and a user who should not. A false canUserEditValue result should keep the value read-only. For an editable source, confirm that setValues persists the change to the underlying data and that the server-side source subsequently renders the saved value.
Repeat these checks after changing WordPress versions. The handbook’s compatibility list and editor behavior can expand, so a binding that works on one release should still be checked against the exact release deployed to production.
Troubleshooting common failures
The source is never called
- Confirm the PHP registration runs on
init. - Check that the source name in
metadata.bindingsexactly matches the registered identifier. - Verify that the selected block attribute appears in the compatibility list for the target WordPress release.
The bound value is empty
- Inspect the argument name in
args; the callback receives it exactly as supplied. - Check that the callback receives the context it expects, especially
postId. - For post meta, verify that the key is REST-exposed and does not begin with an underscore.
- Return a deliberate fallback or
nullrather than assuming every post has the field.
The editor shows stale data or will not save
- Use the JavaScript registration available in WordPress 6.7 and later.
- Implement
getValuesfor the editor’s current value andsetValuesfor persistence. - Check
canUserEditValue; a false result intentionally makes the value read-only. - Ensure the JavaScript and PHP source names and context declarations are identical.
The binding works on one block but not another
Compatibility is attribute-specific, not just block-specific. For example, a source that works for paragraph content does not automatically work for an unsupported attribute on another block. Compare the exact block-and-attribute pair with the release handbook.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Implementation checklist
- Confirm the site runs WordPress 6.5 or newer; require 6.7 or newer for editor-side registration.
- Verify that the target block attribute is supported in the WordPress release you deploy.
- Use a built-in source if it already exposes the required data.
- Register a custom source on
initwith a lowercase, namespaced identifier. - Request only the context keys the callback needs.
- Place the source and optional arguments under
metadata.bindings. - For post meta, register the field with
show_in_rest=trueand avoid underscore-prefixed keys. - Add JavaScript
getValues,setValuesand edit-permission logic only when editor behavior requires it. - Keep fallback attribute content so a missing source value degrades cleanly.
- Test both a post with the field populated and a post where it is absent, then test the editor with a user who should and should not be allowed to edit.
Version reference
| WordPress version | Relevant capability |
|---|---|
| Before 6.5 | Block Bindings API is not available. |
| 6.5 and later | Block Bindings API, compatible attributes, built-in sources and PHP source registration. |
| 6.7 and later | JavaScript registerBlockBindingsSource(), editor value retrieval, persistence hooks and editability control. |
The compatibility list and editor behavior can change as WordPress expands the API. Pin your implementation to the release you support and recheck the handbook when upgrading.
Frequently Asked Questions
How do I bind post meta to a block?
Use the core post-meta source or a custom PHP source. Register the meta key with show_in_rest=true, use a key that does not begin with an underscore, and bind it to a compatible attribute such as paragraph content or button text inside metadata.bindings. Keep fallback content for posts where the field is empty.
Best Value
How do I register a custom Block Bindings source?
Call register_block_bindings_source() on init with a lowercase namespaced identifier such as my-plugin/product-rating, a label, a get_value_callback, and any required uses_context keys. The callback receives source arguments, the block instance and the attribute name.
Which WordPress blocks support bindings?
The default handbook list includes image attributes id, url, title, alt and caption; heading and paragraph content; button url, text, linkTarget and rel; navigation-link and navigation-submenu url; and post-date datetime. Check the handbook for the exact release you support.
Can I edit a bound value in the editor?
Yes, but editor editing requires WordPress 6.7 or later and JavaScript registration with getValues, setValues and canUserEditValue. The setter must persist the underlying value, and permissions must be enforced by the persistence layer as well as the editor UI.
Do I need JavaScript for a read-only binding?
No. A server-side PHP source is sufficient when the value only needs to render on the front end. Add JavaScript when the editor must retrieve a current value, expose read-only editor previews, save edits or apply editability rules.
Why does a binding work for one attribute but not another?
Bindings are compatible with specific block-and-attribute pairs, not automatically with every attribute. Confirm that the exact attribute appears in the compatibility list for your WordPress release, then verify the source name, arguments and required context.
What context should a custom source request?
Request only the keys the callback needs. Use postId for post-specific data and add postType when the callback needs the post type. Declare matching context with PHP uses_context and, when applicable, JavaScript usesContext.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →The Bottom Line
Start with a compatible block attribute and a built-in source. For custom data, register a namespaced PHP source on init, pass it explicit arguments and only the context it needs, and keep fallback content in the block. Use WordPress 6.7+ JavaScript registration only when the editor must read, save or control access to the bound value.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

