0

可以请任何人帮忙吗?我创建了自定义元框,其中两个在 textarea 中。这就是我所拥有的:

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() ) );

但没有运气。任何人都可以帮忙。整个想法是制作像富文本编辑器一样的常规文本区域

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

4

1 回答 1

0

迟到总比不来……

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

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
    ) );
}
于 2015-12-22T07:42:06.040 回答