WordPress 添加 wp_editor 到 custom_meta_box

Wordpress add wp_editor to custom_meta_box

请问有人帮忙吗?我创建了自定义元框,其中两个在文本区域中。 这是我拥有的:

array(
        'label'=> 'Ingredients',
        'desc'  => 'List of ingrediends',
        'id'    => $prefix.'ingrediends',
        'type'  => 'textarea'
    ),
        array(
        'label'=> 'Directions',
        'desc'  => 'Directions',
        'id'    => $prefix.'directions',
        'type'  => 'textarea'
    )

============================

case 'textarea':
    echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="60" rows="4">'.$meta.'</textarea>
        <br /><span class="description">'.$field['desc'].'</span>';
break; 

如何添加 wp_editor?我试过了:

wp_editor( $content, 'recipe_directions', array( 'textarea_name' => 'recipe_directions', 'media_buttons' => false, 'tinymce' => array() ) );

但运气不好。谁能帮忙。 整个想法是使常规文本区域像富文本编辑器

感谢您的帮助....任何人:)

宁可迟到也不到.....

在你的 class 初始化函数中(假设它是一个插件 class)添加

add_meta_box(
    'ingredients_box_id',
    __( 'Ingredients', $this->textdomain ),
    array($this,'ingredients_box_content'),
    'ingredients_box',
    'advanced',
    'high'
);

然后添加函数启用wp_Editor

function ingredients_box_content( $post )
{
    wp_editor( $meta_biography, 'ingredients_box_text_id', array(
        'wpautop'       => true,
        'media_buttons' => false,
        'textarea_name' => 'ingredients_box_text',
        'textarea_rows' => 10,
        'teeny'         => true
    ) );
}