Autosave problem with custom meta box (3 posts)

  1. Sisir
    Posted 5 years ago #

    Hi, i have make some custom meta box in my custom post type. I did not add any code for handling auto save (i don't know how to). Now when the post is opened in browser and wordpress autosave it, it seem the data in the metabox which not change since last save is gone!! But the box which i have changed the data but not saved yet are saved.

    Can anyone say how do i handle autosave? Here is the code...

    function write_business_dir_options(){
    	global $post;
             $custom = get_post_custom($post->ID);
    		 $address = $custom["bus_dir_address"][0];
    		 $website = $custom["bus_dir_website"][0];
    <p><label>Address: <?php $post->ID; ?></label></p>
    	<p><input type="text" size="50" name="address" value="<?php echo $address;  ?>" /></p>
    	<p><input type="text" name="website" value="<?php echo $website; ?>" /></p>
    function save_business_dir_options(){
    	global $post;
    	 update_post_meta($post->ID, "bus_dir_address", $_POST["address"]);
    	 update_post_meta($post->ID, "bus_dir_website", $_POST["website"]);
  2. Sisir
    Posted 5 years ago #

    If my post not clear let me know. I will post details.

  3. ketanmujumdar
    Posted 5 years ago #

    Your solution is here


    need to add one condition that check if its auto save request or not .

Topic Closed

This topic has been closed to new replies.

About this Topic