删除对编辑器的帖子类型支持:
add_action(
\'init\',
function() {
remove_post_type_support( \'post\', \'editor\');
}
);
现在添加一个只包含
textarea
// print a new meta box
function generic_cb($post) {
$content = (!empty($post->post_content)) ? $post->post_content : \'\';
echo \'<textarea name="content">\'.$content.\'</textarea>\';
}
function add_before_editor($post) {
global $post;
add_meta_box(
\'generic_box\', // id, used as the html id att
__( \'Text Only Content\' ), // meta box title
\'generic_cb\', // callback function, spits out the content
\'post\', // post type or page. This adds to posts only
\'pre_editor\', // context, where on the screen
\'high\' // priority, where should this go in the context
);
do_meta_boxes(\'post\', \'pre_editor\', $post);
}
add_action(\'edit_form_after_title\',\'add_before_editor\');
并保存
// strip your data on save
function strip_post_content_markup($data) {
if (!empty($data[\'post_content\'])) {
$data[\'post_content\'] = strip_tags($data[\'post_content\']);
}
return $data;
}
add_filter(\'wp_insert_post_data\',\'strip_post_content_markup\',1);
这是我能想到的最干净的解决方案。