Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End [wordpress] metaboxes lose data

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #30242
    vezzo
    Member

    when editing a custom post type, if I left the page opened for a minute or so without saving it, the data in the metabox simply disappear, I’ve checked the db and it really disappear!!!
    here is the code:


    function admin_init(){
    add_meta_box("dati_aggiuntivi", "dati aggiuntivi", "dati_aggiuntivi", "appartamenti", "normal", "low");
    }

    //METABOXES
    add_action("admin_init", "admin_init");

    function dati_aggiuntivi() {

    global $post;
    $custom = get_post_custom($post->ID);

    $telefono = $custom["telefono"][0];
    $mail = $custom["mail"][0];
    $referente = $custom["referente"][0];
    $indirizzo = $custom["indirizzo"][0];
    $lat = $custom["lat"][0];
    $lng = $custom["lng"][0];

    $coord=grab_the_coordinates($indirizzo);
    $lat = $coord[0];
    $lng = $coord[0];

    ?>











    }

    //SALVARE DATI METABOXES SITI
    add_action('save_post', 'save_details');

    function save_details(){
    global $post;
    update_post_meta($post->ID, "referente", $_POST["referente"]);
    update_post_meta($post->ID, "telefono", $_POST["telefono"]);
    update_post_meta($post->ID, "mail", $_POST["mail"]);
    update_post_meta($post->ID, "indirizzo", $_POST["indirizzo"]);
    update_post_meta($post->ID, "lat", $_POST["lat"]);
    update_post_meta($post->ID, "lng", $_POST["lng"]);
    }

    and here is the declaretion of the custom post type:

    /* CUSTOM CONTENT TYPES
    ======================================== */
    add_action( 'init', 'mfields_create_custom_post_types', 0 );
    function mfields_create_custom_post_types() {
    register_post_type( 'appartamenti',
    array(
    'labels' => array(
    'name' => _x('Appartamenti', 'post type general name'),
    'singular_name' => _x('Appartamento', 'post type singular name'),
    'add_new' => _x('Aggiungi nuovo', 'Nuovo appartamento'),
    'add_new_item' => __('Aggiungi nuovo appartamento'),
    'edit_item' => __('modifica appartamento'),
    'new_item' => __('Nuovo appartamento'),
    'view_item' => __('Visualizza appartamento'),
    'search_items' => __('Cerca appartamento'),
    'not_found' => __('Nessun risultato'),
    'not_found_in_trash' => __('Nessun risultato nel cestino'),
    'parent_item_colon' => ''),
    'public' => true,
    'publicly_queryable' => true,
    //'exclude_from_search' => true,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => true,
    'capability_type' => 'page',
    'hierarchical' => false,
    'menu_position' => 2,
    'supports' => array('title','editor','thumbnail','excerpts'),
    'menu_icon' => get_stylesheet_directory_uri() . '/images/icon_appartamenti.png'
    )
    );
    }
Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.