This Pro tutorial is the equivalent of our earlier ACF Options Fields in Bricks article but when using Meta Box.
While retrieving the values of fields at the top level in Meta Box settings page is straightforward, we will need to write a custom function to get the values of fields inside a group.
Step 1
Install Meta Box and Meta Box AIO plugins.
Go to Meta Box > Settings Pages and click New Settings Page.
Give it a title of say, “Sitewide”.
Click Publish.
The Settings Page ID should already become sitewide. We will be referring to this slug in a later step.
Step 2
Go to Meta Box → Custom Fields and create fields or import this field group.


Step 3
Click Sitewide in the admin menu and populate the custom fields.

Step 4
To get the value of the phone field in Bricks editor, here’s the dynamic tag:
{mb_sitewide_phone}
where sitewide is the Option name (if present) or the Settings Page ID and phone is the ID of the field in that settings page.
To have the phone number as a link, set the URL (External URL) to:
tel:{mb_sitewide_phone}
Let’s define a custom function to get the value of a specified custom field from inside the specified group on Meta Box Settings page.
Add this in child theme’s functions.php:
// Get value of the specified custom field from inside the specified group on Meta Box Settings page.
function bl_get_mb_group_field_value( $group_id, $field_id ) {
// Avoid Undefined Function Error when Meta Box is not active.
if ( ! function_exists( 'rwmb_meta' ) ) {
function rwmb_meta( $key, $args = '', $post_id = null ) {
return false;
}
}
$group_value = rwmb_meta( $group_id, ['object_type' => 'setting'], 'sitewide' );
$value = isset( $group_value[$field_id] ) ? $group_value[$field_id] : '';
return $value; // Display sub-field value
}
Now we are ready to use the above function like this:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {echo:bl_get_mb_group_field_value(social,facebook)} |
We’ve set our custom function to accept 2 parameters.
- ID of the group
- ID of the field
References
https://docs.metabox.io/extensions/meta-box-group/#getting-sub-field-values
https://docs.metabox.io/extensions/mb-settings-page/#getting-field-value