Support Forum
Support › Meta Box Builder › How do draft, publish, and private publish work with MB Builder?Resolved
My first simple custom fields went well. The second, not well at all. I can't find the right spot to see how post (draft, publish, private publish) work with MB draft and publish, so it may related to that. Anyway, here's my code:
add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
function your_prefix_register_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array (
'title' => 'Untitled Meta Box',
'id' => 'untitled-meta-box',
'post_types' => array(
0 => 'post',
),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array (
'id' => 'gvr_test_text_1',
'type' => 'text',
'name' => 'gvr test text 1',
'std' => 'gvr test text 1',
),
array (
'id' => 'gv2_test_textarea_2',
'type' => 'textarea',
'name' => 'Textarea Field',
'std' => 'gv2 test textarea 2',
),
),
);
return $meta_boxes;
}
They show up, along with the proper values - but only after publishing in MB - which makes me wonder what draft is for.
Also don't know if the status of a Post matters - if it's draft, published or private published. Since I don't really want to sent out a test post to my readers, I've been using draft, private post, and unsaved changes to previously published posts. Does that matter? From some of the other forum replies, sounds like it might - but again I can't find the sport that documents this.
When editing a post, the fields / values show up in the MB area in the editor (I use classi mode with TinyMCE Advanced, not Gutenberg). However, unlike my first fields, the Ultimate Short Codes plugin does not display the values.
USC plugin codes:
start
[su_meta key="gvr_non_amp_txt" default="data not found" before="pre txt" after="post txt"]
[su_meta key="gvr_non_amp_msg_1" default="data not found" before="pre msg_1" after="post msg_1"]
end
start
pre txtdata not foundpost txt pre msg_1data not foundpost msg_1
Weird that it's not found, since the fields and the data are displayed properly in the MB area Untitled Meta Box.
What am I doing wrong, and where can I go to get more info on how this actually works?
thanks,
chris
Still working on this - can't just give up. I've made progress. First - found the rwmb_meta shortcode instead of using ShortCodes Ultimate, although they do provide exactly the same output. My question then seems to come down to which field types can actually be output to the page.
Text and Text Area work, but does anything else?
For instance, the Custom HTML fields? They have a value, but don't seem to be able to display them on the page.
Thanks,
chris
Hi Chris,
The status of field groups created by Meta Box Builder works like this:
So, a draft field group is like something you're working on and not ready for users to enter data to.
It doesn't matter if your posts are published, draft or private. In other words, the post status doesn't play any role in the field group settings.
My question then seems to come down to which field types can actually be output to the page.
All field types that have value will display on pages. Fields that don't have value like custom HTML, you should output it yourself.
A quick note for custom HTML field, it accepts a callback
function that you can use to output the content in both back end and front end.
Got it. The conditional logic is especially useful.
Thanks for your help!
chris