我最近切换了主题,并从旧功能复制了我的元数据库。php转换为新的。它们会出现,但当我单击“发布/编辑”时,它们不会保存
add_action( \'add_meta_boxes\', \'cd_meta_box_add\' );
function cd_meta_box_add() {
add_meta_box( \'my-meta-box-id\', \'Video\', \'omc_video_encode\', \'post\', \'normal\', \'high\' );
add_meta_box( \'my-meta-box-id-a\', \'Audio\', \'omc_audio_encode\', \'post\', \'normal\', \'high\' );
add_meta_box( \'my-meta-box-id-d\', \'Download\', \'download_link\', \'post\', \'normal\', \'high\' );
}
function omc_video_encode() {
?>
<label for="omc_video_encode">Iframe here.</label>
<input style="width: 500px;" type="text" name="omc_video_encode" id="omc_video_encode" />
<?php
}
function omc_audio_encode() {
?>
<label for="omc_audio_encode">Jwplayer here.</label>
<input style="width: 500px;" type="text" name="omc_audio_encode" id="omc_audio_encode" />
<?php
}
function download_link() {
?>
<label for="download_link">Link here.</label>
<input style="width: 500px;" type="text" name="download_link" id="download_link" />
<?php
}
add_action( \'save_post\', \'cd_meta_box_save\' );
function cd_meta_box_save( $post_id ) {
// Bail if we\'re doing an auto save
if ( defined( \'DOING_AUTOSAVE\' ) && DOING_AUTOSAVE )
return;
// if our nonce isn\'t there, or we can\'t verify it, bail
if ( !isset( $_POST[\'meta_box_nonce\'] ) || !wp_verify_nonce( $_POST[\'meta_box_nonce\'], \'my_meta_box_nonce\' ) )
return;
// if our current user can\'t edit this post, bail
if ( !current_user_can( \'edit_post\' ) )
return;
}