1

Can please anyone help? I created custom meta boxes, two of them are in textarea. This is what i have:

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; 

How do i add wp_editor? I tried:

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

But it doesn't work still showing regular field. Can anyone help. The whole idea is to make regular textarea like rich text editor

Thanks for your help .... anyone:)

  • what do you mean by "no luck" ? – mmm Jul 27 '15 at 21:46
  • i mean it doesn't work for me, still showing regular field, no editor – www.acreative.ca Jul 27 '15 at 23:04
  • is anyone here can help?? – www.acreative.ca Jul 29 '15 at 17:01
2

To use wp_editor() you'll need to replace your textarea tag with the output from wp_editor() like so:

case 'textarea':
    wp_editor($meta, $field['id']);
    echo '<br /><span class="description">'.$field['desc'].'</span>';
break; 

You don't need to echo wp_editor() since it does it automatically. You can pass an array of settings as a 3rd argument to configure it's behaviour. More info here:

https://codex.wordpress.org/Function_Reference/wp_editor

  • 1
    Great! Glad it worked out for you. Would you mind accepting the answer so I can get the reputation? – aaron.cimolini Aug 15 '15 at 5:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.