您正在使用:
// only low case [a-z], no hyphens and underscores
$editor = \'contenten\';
然后尝试使用不同的名称获取它:
if(isset($_POST[\'content_en\']) && $_POST[\'content_en\'] != \'\')
另一件事是你使用不同的键,如@vancoder所说
还要记住清理数据:https://codex.wordpress.org/Data_Validation
此代码适用于u:
function __construct() {
add_action(\'edit_form_after_editor\', array($this, \'custom_meta_box_lang\'));
add_action(\'save_post\', array($this, \'save_en_content\'));
}
function custom_meta_box_lang(){
global $post;
// set \'your_meta_key\' to the actual key
$content = get_post_meta($post->ID, \'content_en\', true);
// only low case [a-z], no hyphens and underscores
$editor = \'contenten\';
// See my comment below
$editor_settings = array(
\'wpautop\' => true,
\'media_buttons\' => true,
\'textarea_name\' => \'content_en\',
\'textarea_rows\' => 10,
\'drag_drop_upload\' => true);
wp_editor( stripslashes( $content ), $editor, $editor_settings);
}
function save_en_content($post_id){
if(isset($_POST[\'contenten\']) && $_POST[\'contenten\'] != \'\')
update_post_meta($post_id, \'content_en\', $_POST[\'contenten\']);
else
delete_post_meta($post_id, \'content_en\');
}