Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/05/2012, 07:36
Avatar de damian.adriel
damian.adriel
 
Fecha de Ingreso: junio-2007
Mensajes: 35
Antigüedad: 16 años, 10 meses
Puntos: 0
Problema: se borran valores custom post type

Hola:

Tengo el siguiente problema, he creado un Custom Post Type, con un pequeño campo de texto para almacenar vaores.

Al precionar el botón publicar se guardan sin problemas en la base de datos.

Pero al transcurrir varios segundos se borran automaticamente. He probado con un codigo similar que suba imagenes y no hay problema.

Porque puede ser el problema ?. Aqui copio mi código:

Código PHP:
Ver original
  1. function noticias() {
  2.  
  3.     $labels = array(
  4.         'name' => _x('Noticias', 'post type general name'),
  5.         'singular_name' => _x('Noticias', 'post type singular name'),
  6.         'add_new' => _x('Agregar Nueva', 'Noticia'),
  7.         'add_new_item' => __('Agregar Nueva Noticia'),
  8.         'edit_item' => __('Editar Noticias'),
  9.         'new_item' => __('Nuevo Noticia'),
  10.         'view_item' => __('Ver Noticia'),
  11.         'search_items' => __('Buscar Noticias'),
  12.         'not_found' =>  __('Nada encontrado'),
  13.         'not_found_in_trash' => __('Nada encontrado en papelera'),
  14.         'parent_item_colon' => ''
  15.     );
  16.  
  17.     $args = array(
  18.         'labels' => $labels,
  19.         'public' => true,
  20.         'publicly_queryable' => true,
  21.         'show_ui' => true,
  22.         'query_var' => true,
  23.         'rewrite' => true,
  24.         'capability_type' => 'post',
  25.         'hierarchical' => true,
  26.         'menu_position' => null,
  27.         'rewrite'   => array( 'slug' => 'auctions' ),
  28.         'has_archive' => true,
  29.         'supports' => array('title','editor', 'excerpt','thumbnail','comments','author','page-attributes')
  30.     );
  31.  
  32.     register_post_type( 'noticias' , $args );
  33. }
  34.  
  35. function admin_init(){
  36.     add_meta_box("texto", "Texto", "texto", "noticias", "normal", "low");
  37. }
  38.  
  39. function texto(){
  40.     global $post;
  41.     $custom = get_post_custom($post->ID);
  42.     $contenido = $custom["contenido"][0];
  43.     ?>
  44.     contenido: <input name="contenido" type="text" id="contenido" size="100" value="<?php echo $contenido; ?>" />
  45. }
  46. add_action('save_post', 'save_texto');
  47.  
  48. function save_texto(){
  49.   global $post;
  50.  
  51.   update_post_meta($post->ID, "contenido", $_POST["contenido"]);
  52. }

Muchas gracias, espero me puedan ayudar.