Hey,
I'm trying to add the post id as a field value to a field in a field group that I have already set up using the UI.
Here is my code which I'm running on every page at plugins_loaded, but it's not working. Can you help?
add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
$postID = null;
if ( isset( $_GET['post'] ) ) {
$postID = intval( $_GET['post'] );
} elseif ( isset( $_POST['post_ID'] ) ) {
$postID = intval( $_POST['post_ID'] );
}
$meta_boxes[] = [
'title' => 'Orders',
'post_types' => 'Order',
'fields' => [
[
'name' => 'Order ID',
'id' => 'orderID',
'type' => 'number',
'std' => $postID,
],
],
];
return $meta_boxes;
} );