Before I ask the question, I tried to added _ to the custom field, but it's not working, at least with my code.
I just want to hide the value of my meta box from appearing in the custom fields. When I added _ to the code, the metabox stopped working.
Here's the code:
//Creating a MetaBox for Posts to enter audio Code.
add_action('add_meta_boxes','audio_meta_box');
function audio_meta_box(){
add_meta_box('audio_box_id', 'Enter Audio ' , 'audio_box_cb','post','normal','default');
}
function audio_box_cb($post){
$value = get_post_meta($post->ID,'_audio_box',true);
echo '<textarea rows="1" style="width: 98%;" id="audio_box", name="audio_box">';
echo $value;
echo '</textarea>';
}
add_action('save_post','save_audio_box');
function save_audio_box($post_id){
$box_data = $_POST['audio_box'];
update_post_meta($post_id,'_audio_box',$box_data, true);
}
_
in the code you are showing, so I guess you are showing the working code, it would be better, I think, if you show the not working code. Besides that I don't see a reasons why prefixing the post meta keyaudio_box
with_
like this_audio_box
to make it hidden shouldn't work.$box_data = $_POST['audio_box'];
as well.textarea
tag hasrows
andcols
as required attributes. Besides you have a comma in your code that shouldn't be there. Additionally I think there is a misunderstanding, because the value of the$_POST
variable isn't (necessarily) identical with your post meta, it is determined by the name of the form field, so prefixing it won't do anything for you. Last but not least, it is likely that your are just seeing the old post meta entry, which you haven't prefixed.