我正在为我的自定义帖子类型创建一个meta box。有多个领域,我想使用所见即所得编辑器,而不是<textarea>
。可以在一个meta box中添加多个编辑器吗?
我真的很感谢你的帮助!
非常感谢。Dasha
发布于 2012-03-10 22:14:38
到目前为止,http://codex.wordpress.org/Function_Reference/wp_editor是我发现的最简单的方法,从3.3开始内置于Wordpress中(所以升级;-)
发布于 2012-03-20 04:11:07
但是你需要用nl2br()函数来替换presentation,因为自定义模板中的文本区域有toogle JS问题,它会删除所有的<P>
和<br/>
标签,因此会删除所有的换行符。
发布于 2015-07-29 22:45:24
// for custom post type
function wo_second_editor($post) {
echo "<h3>Write here your text for the blue box on the right:</h3>";
$content = get_post_meta($post->ID, 'wo_blue_box' , true ) ;
wp_editor( htmlspecialchars_decode($content), 'wo_blue_box', array("media_buttons" => false) );
}
add_action('edit_form_advanced', 'wo_second_editor');
function wo_save_postdata($post_id, $post, $update) {
//...
if (!empty($_POST['wo_blue_box'])) {
$data=htmlspecialchars($_POST['wo_blue_box']);
update_post_meta($post_id, 'wo_blue_box', $data );
}
}
add_action('save_post', 'wo_save_postdata');
// Theme:
<div class="blue">
<?php
$content = get_post_meta(get_the_ID(), 'wo_blue_box' , true );
$content = htmlspecialchars_decode($content);
$content = wpautop( $content );
echo $content;
?>
</div>
https://stackoverflow.com/questions/3493313
复制相似问题