当我更新帖子时,它的内容会被清除。下面的代码有什么问题?
add_action( \'save_post\', \'eb_save_subpage_data\' );
function eb_save_subpage_data() {
global $post;
if ( $post->post_type == \'subpage\' ) {
update_post_meta( $post->ID, \'title_pl\', esc_attr( $_POST[\'meta_input_title_lang_pl\'] ) );
update_post_meta( $post->ID, \'title_en\', esc_attr( $_POST[\'meta_input_title_lang_en\'] ) );
update_post_meta( $post->ID, \'title_ru\', esc_attr( $_POST[\'meta_input_title_lang_ru\'] ) );
remove_action( \'save_post\', \'eb_save_subpage_data\' );
wp_update_post( array(
\'ID\' => $post->ID,
\'post_title\' => esc_attr( $_POST[\'meta_input_title_lang_pl\'] ),
\'post_name\' => sanitize_title( $post->post_title )
) );
add_action( \'save_post\', \'eb_save_subpage_data\' );
}
}