WordPress.org

Ready to get started?Download WordPress

Forums

Autosave problem with custom meta box (3 posts)

  1. prionkor
    Member
    Posted 3 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><label>Website:</label></p>
    	<p><input type="text" name="website" value="<?php echo $website; ?>" /></p>
    <?php
    }
    
    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. prionkor
    Member
    Posted 3 years ago #

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

  3. ketanmujumdar
    Member
    Posted 3 years ago #

    Your solution is here

    http://techwithketan.wordpress.com/2011/04/14/auto-save-problem-for-custom-variables/

    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