Erstellen Sie Meta-Boxen, die nicht in benutzerdefinierten Feldern angezeigt werden

Ich habe den folgenden Code verwendet, um eine Metabox für Beiträge zu erstellen. Diese Metaboxen werden auch in den benutzerdefinierten Feldern angezeigt.

Ich möchte nicht, dass diese Metaboxen in benutzerdefinierten Feldern angezeigt werden. Gibt es eine Möglichkeit, Meta-Felder in benutzerdefinierten Feldern nicht anzuzeigen?

$meta_boxes_video = array( "hotel name1" => array( "name" => "hotel_name1", "type" => "input", "title" => "Hotel Name (Required)", "description" => ""), "price1" => array( "name" => "price1", "type" => "input", "title" => "Price", "description" => ""), "hotel name2" => array( "name" => "hotel_name2", "type" => "input", "title" => "Hotel Name (Required)", "description" => ""), "price2" => array( "name" => "price2", "type" => "input", "title" => "Price", "description" => ""), "hotel name3" => array( "name" => "hotel_name3", "type" => "input", "title" => "Hotel Name (Required)", "description" => ""), "price3" => array( "name" => "price3", "type" => "input", "title" => "Price", "description" => ""), "hotel name4" => array( "name" => "hotel_name4", "type" => "input", "title" => "Hotel Name (Required)", "description" => ""), "price4" => array( "name" => "price4", "type" => "input", "title" => "Price", "description" => ""), "hotel name5" => array( "name" => "hotel_name5", "type" => "input", "title" => "Hotel Name (Required)", "description" => ""), "price5" => array( "name" => "price5", "type" => "input", "title" => "Price", "description" => ""), "hotel name6" => array( "name" => "hotel_name6", "type" => "input", "title" => "Hotel Name (Required)", "description" => ""), "price6" => array( "name" => "price6", "type" => "input", "title" => "Price", "description" => ""), "img_name1" => array( "name" => "img_name1", "type" => "input", "title" => "Img1 (Required)", "description" => ""), "img_name2" => array( "name" => "img_name2", "type" => "input", "title" => "img2 (Required)", "description" => ""), ); function display_video_meta_boxes() { global $post, $meta_boxes_video; foreach($meta_boxes_video as $meta_box) { echo''; echo'

'.$meta_box['title'].'

'; if( $meta_box['type'] == "input" ) { $meta_box_value = get_post_meta($post->ID, $meta_box['name'].'_value', true); if($meta_box_value == "") $meta_box_value = $meta_box['std']; $meta_box_value = str_replace("\"","'",$meta_box_value); echo'
'; } elseif( $meta_box['type'] == "textarea" ) { $meta_box_value = get_post_meta($post->ID, $meta_box['name'].'_value', true); if($meta_box_value == "") $meta_box_value = $meta_box['std']; $meta_box_value = str_replace("\"","'",$meta_box_value); echo'
'; } elseif( $meta_box['type'] == "button" ) { $meta_box_value = "Add New Source"; if($meta_box_value == "") $meta_box_value = $meta_box['std']; $meta_box_value = str_replace("\"","'",$meta_box_value); echo ' function test() { alert("fgfg"); var element = document.createElement("textarea"); element.setAttribute("value", "Dfdsf"); element.setAttribute("name", "sdfdf"); var foo = document.getElementById("foo"); foo.appendChild(element); } '; echo '
'; echo'
'; } elseif ( $meta_box['type'] == "select" ) { echo''; foreach ($meta_box['options'] as $option) { echo'ID, $meta_box['name'].'_value', true) == $option ) { echo ' selected="selected"'; } elseif ( $option == $meta_box['std'] ) { echo ' selected="selected"'; } echo'>'. $option .''; } echo''; } elseif ($meta_box['type'] == "info") { echo '

Add your property images using the "Upload/Insert" button above the content textbox..

'; } echo'

'; } } function create_video_meta_box() { if (function_exists('add_meta_box')) { add_meta_box( 'ameta_boxes', 'Extra Information', 'display_video_meta_boxes', 'post', 'normal', 'high' ); } } function save_video_postdata( $post_id ) { global $post, $meta_boxes_video; if( get_post_type() == 'post' ) { foreach($meta_boxes_video as $meta_box) { // Verify if ( !wp_verify_nonce( $_POST[$meta_box['name'].'_noncename'], plugin_basename(__FILE__) )) { return $post_id; } if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can( 'edit_page', $post_id )) return $post_id; } else { if ( !current_user_can( 'edit_post', $post_id )) return $post_id; } $data = stripslashes($_POST[$meta_box['name'].'_value']); if(get_post_meta($post_id, $meta_box['name'].'_value') == "") add_post_meta($post_id, $meta_box['name'].'_value', $data, true); elseif($data != get_post_meta($post_id, $meta_box['name'].'_value', true)) update_post_meta($post_id, $meta_box['name'].'_value', $data); elseif($data == "") delete_post_meta($post_id, $meta_box['name'].'_value', get_post_meta($post_id, $meta_box['name'].'_value', true)); } } } add_action('admin_menu', 'create_video_meta_box'); add_action('save_post', 'save_video_postdata');

Solutions Collecting From Web of "Erstellen Sie Meta-Boxen, die nicht in benutzerdefinierten Feldern angezeigt werden"

Alle Post-Metas werden in den benutzerdefinierten Feldern angezeigt, sofern sie nicht mit einem Unterstrich beginnen.

Um also das Post-Meta aus den benutzerdefinierten Feldern metabox zu entfernen, müssen Sie ihm einfach einen Namen geben, beginnend mit einem Unterstrich. Sie sind dann verantwortlich für das Speichern / Aktualisieren des Post-Metas (Hinzufügen Ihrer eigenen Metabox, falls erforderlich).