您需要添加一个自定义验证/清理回调,并将其挂接到publish_post (和/或draft_post 和/或future_post, 如适用)。例如:
<?php
function wpse_44807_update_custom_post_meta() {
    // Globalize the $post object
    global $post;
    // If our custom post meta key is set, sanitize it;
    // otherwise, return false
    $my_post_custom = ( isset( $_POST[\'_my_post_custom\'] ? wp_filter_nohtml_kses( $_POST[\'_my_post_custom\'] ? false );
    // Now, delete or update our custom post meta key
    if ( false == $my_post_custom ) {
        delete_post_meta( $post->ID, \'_my_post_custom\' );
    } else {
        update_post_meta( $post->ID, \'_my_post_custom\', $my_post_custom );
    }
}
add_action( \'publish_post\', \'wpse_44807_update_custom_post_meta\' );
add_action( \'draft_post\', \'wpse_44807_update_custom_post_meta\' );
?>
 请注意,我正在使用
wp_filter_nohtml_kses() 过滤器,如果您需要视频ID或类似的字母数字,那么这将是合适的。根据预期输入的类型,您对消毒的选择将发生变化。
另外:我使用了一个带有下划线前缀的自定义post meta键,如果要为自定义post meta键定义自定义post meta框,那么这是合适的。(下划线前缀从通用的“自定义字段”元框下拉列表中隐藏此元键。)