Custom post types is one of the important and useful feature wordpress have. But I found something strange when I saved custom meta in wordpress admin it went blank after some time, so I checked ajax requests in firefox firebug and found autosave works once I finished my writing in editor and left that page as its. Then searched for the solution and found we need to add a small condition which will restrict autosave to work in custom meta data. Below is the example for how it works…
WordPress api have a hook save_post which we generaly use to save custom meta
add_action('save_post', 'save_details');
function save_details(){
global $post;
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
return;
if($post->post_type == "mypostype")
{
update_post_meta($post->ID, 'mypostdata', $_POST['mypostdata']);
}
}
Basically important is to add this condition
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
return;
By adding above condition it return ajax request before updating custom data, so it save me and made custom post type more useful.

