Blocks and Block Bindings
6 min read
Two ways to show field values in the block editor, both free:
WPM Field block ( | WPM Fields Block Bindings source ( | |
|---|---|---|
What it is | A dynamic block of its own | A data source for attributes of core blocks |
Best for | Print a field with prefix, suffix, fallback, link or image | Make a paragraph, heading, button or image be the field |
Output |
| the core block's own markup |
Works in query loops | yes | yes |
Both read from the current post, or from each post in a Query Loop, and both use the same field catalog. Password fields never appear in either.
References: group.field[.path]
Both take a field reference of the form group_key.field_key, optionally followed by a path into a Group or Repeater value:
listing.price
listing.details.city (Group field "details", sub-field "city")
listing.items.0.name (Repeater "items", first row, sub-field "name")References are lower-cased and cleaned with sanitize_key() per segment. A reference that does not name a visible field renders as empty. A group that appears only on options pages reads the options value and needs no post.
The WPM Field block
Insert WPM Field (category Text, keywords "custom field", "meta", "dynamic") and pick a field in the sidebar. The block is dynamic: it is rendered on the server each time.
Attributes
Attribute | Type | Default | Description |
|---|---|---|---|
| string |
| The field reference. Empty prints nothing (or the fallback). |
|
|
| See below. Any other value is treated as |
| string |
| Text before the value, in |
| string |
| Text after the value, in |
| string |
| Image size name for |
| string |
| Label for |
| string |
| Printed (escaped) instead of the value when it is empty. Prefix and suffix are not added to a fallback. |
Block supports: wide/full/left/center/right alignment, margin, padding, font size, line height, text and background color, link color.
In saved content:
<!-- wp:wpmcf/field {"field":"listing.price","prefix":"From ","suffix":" EUR","fallback":"Ask for a price"} /-->Formats
| Output |
|---|---|
| The field type's own formatted, escaped HTML (a Select's label, a Link as |
| The value as plain text, escaped. Markup the type adds is dropped. |
|
|
| The image of an Image field (or the first of a gallery) as |
Wrapper: the whole result is inside <div class="wp-block-wpmcf-field"> (plus the block's alignment, color and spacing classes). When there is nothing to print and no fallback, no markup at all is produced.
Verified outputs for a text value Hello <x> & "y" (stored as Hello & "y"):
<div class="wp-block-wpmcf-field">Hello & "y"</div>
<div class="wp-block-wpmcf-field"><span class="wpmcf-field-block__prefix"><P> </span>Hello ...<span class="wpmcf-field-block__suffix"> S</span></div>Which post
The block uses the Query Loop item (postId block context) when there is one, else the current post (get_the_ID()). Values are shown only when the viewer may see that post, with the same rule as WordPress's own post-meta binding: the post is publicly viewable or the viewer can read_post, and it is not password-protected. Otherwise the block prints nothing (or its fallback).
The "WPM Fields" Block Bindings source
Registered as source wpmcf/field with label WPM Fields (WordPress 6.5+). In the editor, select a core block, open the Attributes panel and bind an attribute to a field; the field list shows every field except Password and layout fields. In saved content a binding is block metadata:
<!-- wp:paragraph {"metadata":{"bindings":{"content":{"source":"wpmcf/field","args":{"key":"listing.title"}}}}} -->
<p>Placeholder</p>
<!-- /wp:paragraph -->args.key is the field reference.
What each attribute receives
Attribute | Value |
|---|---|
| the field's URL (URL, Link, Email, File, Image, Page link, Post object, oEmbed fields; empty otherwise) |
| the attachment ID of the Image field |
| the image URL (falls back to the field's URL) |
| the attachment's alt text (falls back to the field's text) |
anything else ( | the field's plain text |
A url/href binding to a field that is not URL-like (plain text) gives an empty URL (verified).
Rich-text attributes (such as a paragraph's content) get the text HTML-escaped, so a literal < stays text (verified: a < b & c renders a < b & c). Attributes core outputs as attributes are escaped by core.
Verified examples:
Block and binding | Rendered |
|---|---|
paragraph |
|
heading |
|
button |
|
button | the Link field's URL |
image | the attachment's |
paragraph bound to a Password or unknown field | an empty paragraph |
paragraph bound to an options-only group | the options value (when the viewer may see it) |
A missing field, an unknown reference or a hidden post gives an empty value: the placeholder text is not kept, so the block renders empty.
Which post
Same as the block: Query Loop item, else the current post, visible to the viewer, else empty.
Options-page values
A reference to a field of a group shown only on options pages works in both the block and bindings, with or without a post. Inside post content, the post author must have the options capability (manage_options by default, or what wpmcf/options/capabilities returns), the same rule as the shortcode. Outside post content during REST requests (editor previews), the current user needs it.
Editor REST routes (internal)
The editor script loads data from two wpmcf/v1 routes. They are for the block UI, not a public API.
Route | Method | Permission | Purpose |
|---|---|---|---|
| GET |
| The field catalog ( |
| POST |
| Live values for the bindings preview: |
Verified: admin and editor get 200, a subscriber 403, a logged-out request 401.
Troubleshooting
Symptom | Cause |
|---|---|
The block shows nothing on the site but works in the editor | The field is empty, the post is private or password-protected for the viewer, or you are outside a post (no |
The field is missing from the picker | It is a Password or layout (tab, accordion) field, or the field group is inactive. |
"WPM Fields" is missing in the Attributes panel | The block does not support bindings, or WordPress is older than 6.5 (the plugin requires 6.6). |
An image field prints the file URL as text | Use |
Page-builder equivalents (Elementor, Bricks, Divi, Breakdance, Oxygen) are in Integrations.
Still stuck? Contact support