multiple instances of tinymce with wp_editor with custom post_type – cant save
-
hi folks, i have added an additional visual editor with wp_editor to my custom post type in a meta box. it looks fine i just cannot manage to save anything. it might be saving, but it for sure is’nt retrieving. Ive been looking for hours online with no success. i am using the latest version of wp. 3.4.x
<?php add_action( 'add_meta_boxes', 'mpc_add_description_meta_box' ); // Add the products Meta Box function mpc_add_description_meta_box() { add_meta_box('mpc_add_description_meta_box', 'Product Description (Language 2)', 'mpc_add_description_meta_box_callback', 'products', 'normal', 'high'); } // the description output function mpc_add_description_meta_box_callback() { global $post; // Noncename needed to verify where the data originated echo '<input type="hidden" name="mpc_products_description_noncename" id="mpc_products_description_noncename" value="'.wp_create_nonce(plugin_basename(__FILE__)).'" />'; // Get the location data if its already been entered $input = get_post_meta($post->ID, 'mpc_products_description', true); // echo '<input type="text" name="mpc_products_description" value="' . $input . '" " />'; wp_editor('', 'mpc_products_description', array('textarea_name' => 'mpc_products_description', 'editor_css' => '<style>#wp-mpc_products_description-editor-container{background-color:white;style="width:100%;}</style>')); echo '<table id="post-status-info" cellspacing="0"><tbody><tr> <td id="wp-word-count">Word count: <span class="word-count_2">0</span></td> <td class="autosave-info"> <span class="autosave-message">?</span> </td> </tr></tbody></table>'; } //save the data add_action('save_post', 'mpc_save_description_meta', 1, 2); // save the custom fields function mpc_save_description_meta($post_id, $post) { // verify this came from the our screen and with proper authorization, // because save_post can be triggered at other times if ( !wp_verify_nonce( $_POST['mpc_products_description_noncename'], plugin_basename(__FILE__) )) { return $post->ID; } // Is the user allowed to edit the post or page? if ( !current_user_can( 'edit_post', $post->ID )) return $post->ID; // OK, we're authenticated: we need to find and save the data // We'll put it into an array to make it easier to loop though. $mpc_description_meta['mpc_products_description'] = $_POST['mpc_products_description']; // Add values of $mpc_description_meta as custom fields foreach ($mpc_description_meta as $key => $value) { // Cycle through the $mpc_description_meta array! if( $post->post_type == 'revision' ) return; // Don't store custom data twice $value = implode(',', (array)$value); // If $value is an array, make it a CSV (unlikely) if(get_post_meta($post->ID, $key, FALSE)) { // If the custom field already has a value update_post_meta($post->ID, $key, $value); } else { // If the custom field doesn't have a value add_post_meta($post->ID, $key, $value); } if(!$value) delete_post_meta($post->ID, $key); // Delete if blank } } ?>
thanks in advance!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘multiple instances of tinymce with wp_editor with custom post_type – cant save’ is closed to new replies.