Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom metabox which uses wp_editor and when i switch to text editor instead of visual the main content tinymce also changes to text view when i update. I was wondering am i doing something wrong or is that normal behavoir for wordpress when creating a custom metabox and wp_editor?

the code i use to set all of this up is:

add_action('add_meta_boxes', 'page_tagline_meta_box');
function page_tagline_meta_box($post) {
    global $post;
    $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
    $homepage_id = get_option('page_on_front');

    $screens = array( 'services', 'page');
    if($homepage_id != $post_id) {
        foreach ($screens as $screen) {
            add_meta_box('page_tagline_id', 'Tagline text & Telephone number', 'page_tagline_meta_box_cb', $screen, 'normal', 'high');
            add_meta_box('additional_content_id', 'Additional Content', 'additional_content_meta_box_cb', $screen, 'normal', 'high');
        }
    }
}
function additional_content_meta_box_cb($post) {
    global $post;
    wp_nonce_field('additional_content_box_nonce', 'additional_content_meta_box_nonce');

    $values = get_post_custom($post->ID);

    $additionalContent = isset($values['additionalContent']) ? $values['additionalContent'][0]: '';

    $settings = array(
        'textarea_rows' => 15,
        'wpautop' => true
    );

    wp_editor($additionalContent, 'additionalcontent', $settings);
}

If you would like to see the save function you are welcome to but i know it all saves and i can get the content out in my templates. its just when i switch views on the custom metabox it also switches the view of the main text area for the page when i hit update which i find quite odd.

Thanks in advance for your help

Alex

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

This is, as you guessed, default behavior. It's stored in the wp_usermeta table for each user in the wp_user-settings meta_key and does not differentiate between different editor instances.

On a side note, the tinymce version of wp_edior() does not cooperate very well with being inside a meta box. Especially if the metabox is moved, or hidden then shown, etc. I'd highly recommend either using the quicktags version only or not using a metabox (use any of a number of hooks in edit-form-advanced.php).

share|improve this answer
    
Hi thanks for the answer. I did read that it isnt ideal to use after i wrote this question and did do some research to try and find some help on the edit-form-advanced but couldn't find anything to learn from. Is there anything you'd suggest i could look at. Im still new to hooks and trying to get my head around them. –  user720414 Oct 29 '13 at 8:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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