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 want something very simple: a custom metabox with a TinyMCE editor in it.

The following code help me achieve that easily in 3.1.4:

add_action( 'add_meta_boxes', 'add_metaname_box');
function add_metaname_box() {
    add_meta_box(
        'metaname_id',
        __( 'metaname text', 'metaname_textdomain'),
        'metaname_custom_box',
        'post'
    );
}

function metaname_custom_box() {
    global $post;
    wp_nonce_field( plugin_basename( __FILE__ ), 'metaname_noncename' );
    $data = get_post_meta($post->ID, 'metaname_custom_box', true);
    echo <<<EOT
    <textarea id="metaname_custom_box" name="metaname_custom_box" class="theEditor">$data</textarea>
EOT;
}

This is what it looked like:
Visual editor in custom meta box

My problem is that this code is no longer works after I upgraded from 3.1.4 to 3.2. This is the result for the same code after upgrading to 3.2:
Regular textfield in custom meta box

The HTML code for TinyMCE is not generated anymore.

However, I noticed that this piece of code still works fine in a fresh installation of WP 3.2. This is the result of the code in fresh installation:
Visual editor in 3.2 style in custom meta box

Can someone help me why my code works fine with 3.1.4 and fresh 3.2, but not in the 3.2 upgraded from 3.1.4 ? How to solve this problem?

share|improve this question
    
If you don't see the problem on a fresh install, it's possible that you have a plugin or theme that interacts with your code. Can you disable all plugins and go back to the normal theme to see whether this solves your problem? (Of course, you should still keep the code that adds your extra meta box) –  Jan Fabry Jul 9 '11 at 14:48
    
Thanks for your answers, Jan. It brought out some thoughts to me and now I think I have found the real problem. It is with the CUSTOM POST TYPE. In 3.2, the above code works fine on DEFAULT TYPES such as POST, PAGE, but it crashed in any CUSTOM POST TYPE. Is there anyone got the same problem can confirm this ? I hope this is not a bug in 3.2. –  Eugene Jul 12 '11 at 11:47
    
If you find the solution, please add it as an answer yourself, so you might help someone else in the future! –  Jan Fabry Jul 12 '11 at 11:51
    
No, not a solution yet. It just I think I have found the real problem. Hope that you or anybody else can replicated this problem and confirm that, so that I don't feel lonely in this world and most important - my plugin's code doesn't cause this. –  Eugene Jul 12 '11 at 11:56
    
Updated: this code does not work in CUSTOM POST TYPE, with no 'editor' specified in the 'supports' args array. –  Eugene Jul 12 '11 at 14:15
show 2 more comments

1 Answer

Found the solution. I'll put it here in case anyone stumbles on the same problem. According to here, this code helped me solve my problem:

add_action("admin_head","myplugin_load_tiny_mce");

function myplugin_load_tiny_mce() {

wp_tiny_mce( false ); // true gives you a stripped down version of the editor

}
share|improve this answer
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.