How to add editor wysiwyg in metabox

This is example how to add editor in metabox.

First here add your metabox:

function custom_metabox() {
    add_meta_box('name for metabox', __('title for metabox', 'your theme name'), 'your function', 'post or your custom post type');

add_action('add_meta_boxes', 'custom_metabox');

Then create visualization for your metabox:

function your function() {
    global $post;

    $content = get_post_meta($post->ID, 'your meta key', true);
    $editor_id = 'your editor name'; // this is editor which to use
    wp_editor($content, $editor_id); // here is editor

And here is save:

add_action('save_post', 'your function for save');

function your function for save() {
    $editor_id = 'your editor name';
    $meta_key = 'your meta key';
    if (isset($_REQUEST[$editor_id])):
        update_post_meta($_REQUEST['post_ID'], $meta_key, $_REQUEST[$editor_id]);

This method I use here in my site for short description in posts – selected text in picture. And the link: my site

custom meta box
custom meta box



28 thoughts on “How to add editor wysiwyg in metabox

  1. My partner and I stumbled over here from a different website
    and thought I may as well check things out. I
    like what I see so now i’m following you. Look forward to looking into your web page yet again.

  2. Howdy I am so glad I found your website, I really found
    you by accident, while I was researching on Bing for something
    else, Anyways I am here now and would just like to say thanks for a marvelous post and a
    all round enjoyable blog (I also love the theme/design), I don’t have time
    to read through it all at the moment but I have book-marked it and also added in your RSS feeds, so when I have time I will be back to read much more, Please do keep
    up the fantastic work.

  3. Admiring the time and energy you put into your blog and detailed information you offer.
    It’s good to come across a blog every once in a while that isn’t
    the same outdated rehashed material. Great read!
    I’ve saved your site and I’m adding your RSS
    feeds to my Google account.

    Visit my site: Dyson Vacuum

  4. Amazing blog! Is your theme custom made or did
    you download it from somewhere? A design like yours with a few simple adjustements would really make my blog jump out.
    Please let me know where you got your design. Cheers

  5. I do accept as true with all the concepts you’ve presented for your post.

    They are very convincing and will certainly work.
    Nonetheless, the posts are very quick for beginners. May you
    please lengthen them a bit from next time?
    Thanks for the post.

    Here is my homepage :: omnicef

  6. Pingback: car parking

Leave a Reply