I've created a custom post type that needs a WYSIWYG editor for a person's contact information.
The Meta Box displays and the WYSIWYG editor displays but the content does not get saved or spit back out after clicking update. What am I doing wrong? Thanks.
// Create Missionary Meta Box
function my_admin() {
add_meta_box( 'missionary_meta_box',
'Missionary Contact Details',
'display_missionary_meta_box',
'missionaries', 'normal', 'high'
);
}
// Put Fields In Missionary Meta Box
function display_missionary_meta_box( $missionaries ) {
$missionary_contact_details = get_post_meta($post->ID, 'missionary_contact_details', true);
?>
<table>
<tr>
<td><?php wp_editor($missionary_contact_details, 'missionary_contact_details', array(
'wpautop' => true,
'media_buttons' => false,
'textarea_name' => 'missionary_contact_details',
'textarea_rows' => 10,
'teeny' => true
)); ?>
</td>
</tr>
</table>
<?php
}
add_action( 'save_post', 'add_missionary_fields', 10, 2 );
function add_missionary_fields( $missonaries_id, $missionaries ) {
// Check post type for missionary data
if ( $missionaries->post_type == 'missionaries' ) {
// Store data in post meta table if present in post data
if(isset($_POST['missionary_contact_details']) && $_POST['missionary_contact_details'] != '')
update_post_meta($post_id, 'missionary_contact_details', $_POST['missionary_contact_details']);
else
delete_post_meta($post_id, 'missionary_contact_details');
}
}