Visually bind post meta to core WordPress blocks using the Block Bindings API. No code required.
Block Binder provides a user-friendly sidebar panel in the WordPress block editor that lets you:
- Select a block — Choose from 16+ supported core blocks
- Pick an attribute — Text, URL, image, caption, etc.
- Bind to post meta — Connect to any post meta key on your site
- Done — The block automatically displays the meta value on the frontend
No hardcoding, no custom code, no complexity. Just point and bind.
✨ Visual Block Binding Interface
- Sidebar panel appears when a supported block is selected
- Intuitive dropdowns for attributes and meta keys
- Real-time binding status indicator
📦 16+ Supported Blocks
core/paragraph,core/heading(h1–h6)core/image,core/button,core/list,core/quotecore/audio,core/video,core/columns,core/columncore/cover,core/file,core/gallery,core/tablecore/preformatted,core/verse
🔄 Dynamic Meta Key Discovery
- Automatically discovers meta keys from your site's database
- Shows meta keys from published and draft posts
- Merges with registered meta keys via
register_meta()
⚡ REST API Integration
- Asynchronous meta key loading
- Zero page load overhead
- Fresh data every time you open the editor
🔒 Secure & Compliant
- Respects WordPress security standards
- Nonce verification on all REST endpoints
- Capability checks (
edit_posts) - Sanitized inputs and escaped output
- WordPress 6.5 or higher (requires Block Bindings API)
- PHP 7.4 or higher
- Block editor support (Gutenberg)
# Clone the repository
git clone https://github.com/laxmariappan/block-binder.git
# Install into WordPress
mv block-binder ~/path/to/wp-content/plugins/
# Navigate to the plugin directory
cd wp-content/plugins/block-binder
# Install dependencies
npm install
# Build the plugin
npm run build
# Activate in WordPress admin or via WP-CLI
wp plugin activate block-binderOnce published to the WordPress plugin repository, you can:
- Go to Plugins > Add New in WordPress admin
- Search for "Block Binder"
- Click Install Now and then Activate
-
Edit a Post/Page
- Open any post or page in the block editor
-
Select a Supported Block
- Click on a Paragraph, Heading, Image, Button, or other supported block
-
Open Block Binder Panel
- Look for "Block Binder" in the document settings sidebar (right panel)
- If not visible, click the "Settings" icon in the toolbar
-
Choose an Attribute
- Select which attribute to bind (e.g., "content" for Paragraph, "url" for Image)
-
Select a Meta Key
- Choose a post meta key from the dropdown
- The dropdown auto-populates with meta keys from your site
-
Bind the Connection
- Click the Bind button
- The binding is saved to the block's metadata
-
Unbind (Optional)
- Click Unbind to remove an existing binding
Suppose you have:
- A Paragraph block in your post
- A post meta key called
book_authorcontaining "Jane Smith"
Steps:
- Select the Paragraph block
- Open Block Binder panel
- Attribute: Choose "content"
- Meta Key: Choose "book_author"
- Click Bind
Result: The paragraph will now display "Jane Smith" on the frontend, pulling from the post meta.
- Paragraph, Heading →
content - Preformatted, Verse →
content
- Image →
url,alt,title,caption - Audio, Video →
src,caption - File →
href,fileName,textLinkTarget
- Button →
text,url,title - List →
values - Quote →
value,citation - Columns, Column →
className - Cover →
backgroundImageUrl,title,subtitle - Gallery, Table →
caption
block-binder/
├── block-binder.php # Main plugin file (179 lines)
├── README.md # GitHub documentation (this file)
├── readme.txt # WordPress.org format
├── package.json # npm configuration
├── src/
│ └── index.js # React component for sidebar panel
├── build/ # Compiled output (gitignored)
│ ├── index.js # Minified bundle (3.78 KiB)
│ └── index.asset.php # Dependency manifest
└── .gitignore # Excludes build/ and node_modules/
# Clone and install
git clone https://github.com/laxmariappan/block-binder.git
cd block-binder
npm install
# Watch mode — rebuild on file changes
npm start
# Build for production
npm run build
# Lint JavaScript
npm run lint
# Format code
npm run formatThe plugin uses @wordpress/scripts for building:
npm run build # One-time production build
npm start # Watch mode (hot reload)Output:
build/index.js— Compiled React component (minified)build/index.asset.php— Dependency manifest (auto-generated)
PHP (block-binder.php):
block_binder_enqueue_assets()— Loads the sidebar scriptblock_binder_register_binding_source()— Registers the custom binding sourceblock_binder_register_rest_endpoint()— Registers REST API endpointblock_binder_rest_get_meta_keys()— Fetches available meta keysblock_binder_get_meta_value()— Retrieves post meta values for frontend rendering
JavaScript (src/index.js):
BlockBinderPanel()— React component for the sidebar UIuseEffect()hook — Fetches meta keys via REST API on component mountuseState()hooks — Manages selected attribute, meta key, and loading statehandleBind()— Writes binding metadata to block attributeshandleUnbind()— Removes binding metadata
Endpoint: GET /wp-json/block-binder/v1/meta-keys
Response:
{
"meta_keys": ["book_author", "_description", "custom_field", ...]
}Permission: Requires edit_posts capability
Security: Nonce verification via X-WP-Nonce header
Block Binder registers a custom binding source with WordPress:
register_block_bindings_source(
'block-binder/post-meta',
[
'label' => 'Post Meta (Block Binder)',
'get_value_callback' => 'block_binder_get_meta_value',
]
);When a block is bound, WordPress stores the binding in the block's metadata.bindings object:
{
"metadata": {
"bindings": {
"content": {
"source": "block-binder/post-meta",
"args": {
"key": "book_author"
}
}
}
}
}On the frontend, WordPress's Block Bindings API automatically pulls the post meta value and renders it in place of the hardcoded attribute.
Dynamic Meta Key Loading (REST API):
- Previously: Database query on every page load → slow
- Now: Async REST call after editor loads → instant UI + background data fetch
- Meta keys update fresh every time you open the editor panel
✅ Capability Checks — Only users who can edit_posts can access the binding interface
✅ Nonce Verification — REST endpoints use WordPress nonce validation
✅ Input Sanitization — All meta keys are sanitized with sanitize_key()
✅ Output Escaping — Block attributes are properly escaped by WordPress
✅ SQL Prepared Statements — Database queries use $wpdb->prepare()
- Check WordPress version: Block Binder requires WordPress 6.5+
- Check PHP version: PHP 7.4+ is required
- Make sure plugin is activated: Go to Plugins and verify "Block Binder" is active
- Refresh the editor: Close and reopen the block editor
- Wait for loading: The dropdown shows "Loading..." while fetching. Wait a moment.
- Check REST API: Verify
/wp-json/block-binder/v1/meta-keysis accessible - Verify posts exist: Block Binder discovers meta keys from published/draft posts. Make sure you have posts with the meta keys you're looking for.
- Check WordPress version: Block Bindings API requires WordPress 6.5+
- Verify binding saved: Look for "Current binding:" text in the Block Binder panel
- Check post meta value: Ensure the post meta key actually has a value
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Initial release
- REST API for dynamic meta key loading
- Support for 16+ core blocks
- Visual binding interface in sidebar
- Secure capability and nonce checks
- WordPress.org compliant documentation
Block Binder is licensed under the GPL v2 or later.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
See LICENSE.txt for full details.
Author: Lax Mariappan
Contributors: Oz AI Assistant
Built with ❤️ for the WordPress community.
- GitHub Issues: Report bugs or request features
- Discussions: Ask questions and share ideas
- WordPress.org: Plugin page (coming soon)
Made with WordPress ❤️