I can remember I did run into this before, but I do not know how I solved it.
There must be something obvious I am missing. I used Meta Box AIO for code generation and did look at https://docs.metabox.io/extensions/mb-settings-page/#getting-field-value, but I can't see anything wrong.
I did a bare-bones theme for testing:
functions.php
<?php
//all code is generated from Meta Box AIO
add_filter('rwmb_meta_boxes', 'custom_fields');
function custom_fields($meta_boxes)
{
$prefix = '';
$meta_boxes[] = [
'title' => __('custom_field_title', 'your-text-domain'),
'id' => 'custom_field_title',
'settings_pages' => ['settings_page_titel'],
'fields' => [
[
'name' => __('Text', 'your-text-domain'),
'id' => $prefix.'custom_field',
'type' => 'text',
],
],
];
return $meta_boxes;
}
add_filter('mb_settings_pages', 'custom_settingspage');
function custom_settingspage($settings_pages)
{
$settings_pages[] = [
'menu_title' => __('settings_page_titel', 'your-text-domain'),
'option_name' => 'settings_page',
'position' => 25,
'style' => 'no-boxes',
'columns' => 1,
'icon_url' => 'dashicons-admin-generic',
];
return $settings_pages;
}
index.php
<?php
get_header();
$value = rwmb_meta('settings_page', ['object_type' => 'setting'], 'custom_field');
var_dump($value);
get_footer();
I would expect the output to be:
.../wp-content/themes/test/index.php:12:string 'lorem'
instead I get:
.../wp-content/themes/test/index.php:12:boolean false