在functions.php中添加如下代码


add_action('admin_menu', 'create_meta_box');    //在加载管理员界面界面的时候调用create_meta_box函数    add_action('save_post', 'save_postdata');     function create_meta_box(){     if(function_exists('add_meta_box')){            //add_meta_box函数在文章编辑页面内添加版块,具体用法放在文章最后            add_meta_box('new-meta-box','自定义模块','new_meta_box','post','normal','high');            //此函数调用new_meta_box函数        } }  function new_meta_box(){     global $post;        $meta_box_value = get_post_meta($post->ID, 'answer', true);          echo '<h4>答案</h4>';        wp_editor(str_replace('\"','"',$meta_box_value), 'answer', $settings = array(quicktags=>1,                     tinymce=>1,                     media_buttons=>0,                     textarea_rows=>4,                        editor_class=>"textareastyle") );  }  function save_postdata($post_id){     global $post;     $data = wpautop($_POST['answer']);     if(get_post_meta($post_id,'answer') == "")            add_post_meta($post_id,'answer', $data, true);        elseif($data != get_post_meta($post_id,'answer', true))            update_post_meta($post_id,'answer', $data);        elseif($data == "")            delete_post_meta($post_id,'answer', get_post_meta($post_id,'answer', true));    }


前台调用代码:


echo get_post_meta($post->ID, 'answer', true);



效果:

黄聪:wordpress后台发布文章,自定义栏目支持HTML,可插入图片_编辑页面