<?php
add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
function your_prefix_function_name( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => __( 'References', 'your-text-domain' ),
'id' => 'references',
'post_types' => ['control'],
'fields' => [
[
'id' => $prefix . 'references',
'type' => 'group',
'clone' => true,
'fields' => [
[
'name' => __( 'Reference Label', 'your-text-domain' ),
'id' => $prefix . 'myreference_label',
'type' => 'text',
],
[
'name' => __( 'Reference URL', 'your-text-domain' ),
'id' => $prefix . 'myreference_url',
'type' => 'url',
],
],
],
],
];
return $meta_boxes;
}
Here's my latest shortcode function:
add_shortcode( 'references', function() {
$group = rwmb_meta( 'references' );
//return $group;
if ( empty( $group ) ) {
return '';
}
$output = '';
// Reference URL
$rlabel = $group['myreference_label'] ?? '';
$rurl = $group['myreference_url'] ?? '';
$output .= '<a href="' . $rurl . '">' . $rlabel . '</a>';
return $output;
});