Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/02/2017, 04:09
yopmail
 
Fecha de Ingreso: agosto-2014
Mensajes: 294
Antigüedad: 9 años, 7 meses
Puntos: 4
Pregunta Como poner muchas veces esta funcion?

Hola, necesito poner una function muchas veces, pero al ponerlo sin cambiar nada se me cae la web, se que hay que cambiar algo.. pero tras probar muchas veces no doy con ello.. Agradeceria un empujon..

Codigo:

Código PHP:
add_action('admin_menu''custom_fields_price');
function 
custom_fields_price() {
    
add_meta_box('price','Precio del Objeto','fn_price','post','normal','high');
}

function 
fn_price() {
    global 
$wpdb$post;
    
$value  get_post_meta($post->IDpricetrue);
    echo 
'<label for="image_es">Precio</label>
    <input type="text" name="price" id="price" value="'
.htmlspecialchars($value).'" style="width: 100px;" /> &euro;';

Código PHP:
add_action('publish_post''save_price');
function 
save_price() {
   global 
$wpdb$post;
    if (!
$post_id$post_id $_POST['post_ID'];
    if (!
$post_id) return $post;
    
$price$_POST['price'];
    
update_post_meta($post_id'price'$price);

+1 por cualquier ayuda que me puedan dar