This skill should be used when the user asks to "use MetaBox", "get custom fields", "update custom fields", "MetaBox REST API", "meta_box fields", mentions "MetaBox plugin", or needs help working with MetaBox custom fields through the WordPress REST API.
From woocommerce-wordpressnpx claudepluginhub orbruno/woocommerce-ccpluginThis skill uses the workspace's default tool permissions.
Designs and optimizes AI agent action spaces, tool definitions, observation formats, error recovery, and context for higher task completion rates.
Comprehensive guide for working with MetaBox custom fields using the MB REST API extension.
Activate this skill when user needs help with:
MetaBox is a powerful WordPress plugin for creating custom fields (meta boxes) without code. The MB REST API extension integrates these custom fields into WordPress's native REST API, making them accessible programmatically.
/wp/v2/{post-type}/{id} endpointsMetaBox adds custom field data to standard WordPress responses under a meta_box key:
{
"id": 123,
"title": "My Post",
"content": "...",
"meta_box": {
"field_1": "value_1",
"field_2": "value_2",
"custom_image": {
"url": "https://example.com/image.jpg",
"width": 1200,
"height": 800
}
}
}
| Content Type | Endpoint | Example |
|---|---|---|
| Posts | /wp/v2/posts/{id} | /wp/v2/posts/123 |
| Pages | /wp/v2/pages/{id} | /wp/v2/pages/456 |
| Custom Post Types | /wp/v2/{post_type}/{id} | /wp/v2/products/789 |
| Categories | /wp/v2/categories/{id} | /wp/v2/categories/10 |
| Tags | /wp/v2/tags/{id} | /wp/v2/tags/20 |
| Custom Taxonomies | /wp/v2/{taxonomy}/{id} | /wp/v2/portfolio-tags/15 |
| Users | /wp/v2/users/{id} | /wp/v2/users/5 |
| Comments | /wp/v2/comments/{id} | /wp/v2/comments/50 |
| Settings Pages | /meta-box/v1/settings-page?id={page_id} | /meta-box/v1/settings-page?id=my-settings |
Get Custom Fields:
metabox_get_post_fields
- post_type: "posts", "pages", or custom post type slug
- id: Post ID
Update Custom Fields:
metabox_update_post_fields
- post_type: Post type slug
- id: Post ID
- fields: Object with field_id: value pairs
Example:
// Get custom fields for a post
{
"post_type": "posts",
"id": 123
}
// Update custom fields
{
"post_type": "posts",
"id": 123,
"fields": {
"author_bio": "Orlando Bruno is a data scientist...",
"featured_flag": true,
"reading_time": 5
}
}
Get Term Fields:
metabox_get_term_fields
- taxonomy: "categories", "tags", or custom taxonomy slug
- id: Term ID
Update Term Fields:
metabox_update_term_fields
- taxonomy: Taxonomy slug
- id: Term ID
- fields: Field updates
Example:
// Get category custom fields
{
"taxonomy": "categories",
"id": 10
}
// Update custom fields
{
"taxonomy": "categories",
"id": 10,
"fields": {
"category_color": "#3498db",
"category_icon": "fa-rocket"
}
}
Get User Fields:
metabox_get_user_fields
- id: User ID
Update User Fields:
metabox_update_user_fields
- id: User ID
- fields: Field updates
Example:
// Update user custom fields
{
"id": 5,
"fields": {
"user_twitter": "@orlandobruno",
"user_linkedin": "linkedin.com/in/orlandobruno",
"user_expertise": ["AI", "Data Science", "Music"]
}
}
Get Comment Fields:
metabox_get_comment_fields
- id: Comment ID
Update Comment Fields:
metabox_update_comment_fields
- id: Comment ID
- fields: Field updates
Settings pages are special MetaBox pages that store site-wide configuration.
IMPORTANT: Settings pages require:
Get Settings Page:
metabox_get_settings_page
- id: Settings page ID (as configured in MetaBox)
Update Settings Page:
metabox_update_settings_page
- id: Settings page ID
- fields: Field updates
Example:
// Get site settings
{
"id": "site-options"
}
// Update site settings
{
"id": "site-options",
"fields": {
"footer_text": "© 2025 Orlando Bruno",
"analytics_id": "UA-123456-1",
"enable_maintenance": false
}
}
MetaBox automatically formats complex field types:
{
"featured_image": {
"url": "https://example.com/image.jpg",
"width": 1200,
"height": 800,
"full_url": "https://example.com/image-full.jpg"
}
}
{
"location": {
"latitude": 9.7489,
"longitude": -83.7534,
"address": "San José, Costa Rica",
"zoom": 12
}
}
{
"related_posts": [123, 456, 789]
}
You can hide specific fields from REST API responses:
In MB Builder:
In Code:
'hide_from_rest' => true
Hidden fields will not appear in meta_box responses and cannot be updated via REST API.
// Use metabox_get_post_fields
{
"post_type": "posts",
"id": 123
}
// Response includes meta_box object with all fields
{
"success": true,
"data": { /* full post data */ },
"meta_box": {
"field_1": "value",
"field_2": "value"
}
}
// Update only the fields you want to change
{
"post_type": "posts",
"id": 123,
"fields": {
"subtitle": "New subtitle",
"author_note": "Updated author note"
}
}
// Other fields remain unchanged
// WooCommerce products are a custom post type
{
"post_type": "product",
"id": 789,
"fields": {
"product_warranty": "2 years",
"product_manual": "https://example.com/manual.pdf",
"eco_friendly": true
}
}
For multiple posts, iterate through IDs:
// Update custom fields for multiple posts
const postIds = [123, 456, 789];
for (const id of postIds) {
await metabox_update_post_fields({
post_type: "posts",
id: id,
fields: {
"review_status": "reviewed",
"reviewed_by": 5
}
});
}
Cause: MB REST API extension not installed or activated
Solution:
metabox_get_post_fields on a post with custom fieldsCause: Settings pages always require authentication
Solution:
Possible Causes:
Solution:
Cause: Custom post type not registered in REST API
Solution:
'show_in_rest' => true in registration'rest_base' => 'custom-slug')metabox_get_post_fieldsField Naming: Use snake_case for field IDs (e.g., author_bio, not Author Bio)
Batch Operations: For large datasets, consider pagination and rate limiting
Error Handling: Always check response success before processing data
Field Validation: Validate field values before updating to prevent data corruption
Documentation: Keep track of field IDs and their purposes for your project
MetaBox works seamlessly with WooCommerce products (which are custom post types):
// Add custom fields to WooCommerce products
{
"post_type": "product",
"id": 456,
"fields": {
"supplier_name": "Acme Corp",
"warranty_period": "24 months",
"eco_certification": true,
"custom_specs": {
"weight": "2.5kg",
"dimensions": "30x20x15cm"
}
}
}
Use the check_connection tool to verify MetaBox is working:
// Test connection (includes MetaBox check)
check_connection
This will return:
{
"metabox": {
"success": true,
"hasMetaBox": true,
"message": "MetaBox REST API is active and working"
}
}
If hasMetaBox is false, the MB REST API extension may not be installed.
Last Updated: 2025-12-26 Plugin Version: 0.1.0