Title: Problems with quick edit
Last modified: September 6, 2023

---

# Problems with quick edit

 *  [sacconi](https://wordpress.org/support/users/sacconi/)
 * (@sacconi)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/problems-with-quick-edit/)
 * If I change the post date with quick edit all the values of custom fields disappear.
   Is there a way to fix this behaviour?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fproblems-with-quick-edit%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Kaito Hanamori](https://wordpress.org/support/users/kaitohm/)
 * (@kaitohm)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/problems-with-quick-edit/#post-17031790)
 * The issue could be in the way custom fields are set up. Are you using a plugin
   for custom fields? Or have you coded them yourself?
 *  Thread Starter [sacconi](https://wordpress.org/support/users/sacconi/)
 * (@sacconi)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/problems-with-quick-edit/#post-17031922)
 * I found the code myself. I.e., here is the code of one custom field:
 *     ```wp-block-code
       // ACTION TO ADD THE META BOX WE ARE DEFINING 
   
       add_action( 'add_meta_boxes_post', "name_add_meta_box" );
   
       /*
        * Routine to add a meta box.  Called via a filter hook once WordPress is initialized
        */
       function name_add_meta_box(){
           add_meta_box(
               "name_meta_box",  // An ID for the Meta Box.  Make it unique to your plugin
               __( "Nome", 'textdomain' ),  // The title for your Meta Box
               "name_meta_box_render",  // A callback function to fill the Meta Box with the desired UI in the editor
               "post",  // The screen name - in this case the name of our custom post type
               "side"  // The context or placement for the meta box.  Choose "normal", "side" or "advanced"
           );
       }
   
       /*
        * Routine to display a custom meta box editor
        * Note: In this example our custom meta data is saved as a row in the postmeta database table.
        * $post PostObject An object representing a WordPress post that is currently being loaded in the post editor.
        */
       function name_meta_box_render( $post ){
   
           // Get the name and display it in a text field
           $name = get_post_meta( $post->ID, "function_name", true );
           echo '<div><input type="text" name="function_name" value="'.$name.'" placeholder="Nome" /></div>';
   
       }
   
       // Hook into the save routine for posts
       add_action( 'save_post', 'name_meta_box_save');
   
       /*
        * Routine to save the custom post meta data from the editor
        * Note: We retrieve the form data through the PHP Global $_POST
        * $post_id int The ID of the post being saved
        */
       function name_meta_box_save( $post_id ){
   
           // Check to see if this is our custom post type (remove this check if applying the meta box globally)
           if($_POST['post_type'] == "post"){
   
               // Retrieve the values from the form
               $name = $_POST['function_name'];
   
   
               // Clean, sanitize and validate the input as appropriate
   
               // Save the updated data into the custom post meta database table
               update_post_meta( $post_id, "function_name", $name );
   
   
           }     
       }
       ```
   
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/problems-with-quick-edit/#post-17033685)
 * You need to verify a value exists before trying to use it. This is a general 
   rule in all coding. If you do not check, the non-existent value gets saved.
    `
   if($_POST['post_type'] == "post" && array_key_exists('function_name', $_POST)){`

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problems with quick edit’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 3 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/problems-with-quick-edit/#post-17033685)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
