Note that there are some explanatory texts on larger screens.

plurals
  1. POupdate_post_meta for Custom Post Type in Wordpress doesn't work
    primarykey
    data
    text
    <p>but I'm trying to create a Custom Post Type, add a Meta Box and save the Custom Filed in it. Now when i click save the value of my input text doesn't save, it remain empty.</p> <p>Here is my code (my first attempt), hope someone may help me, thanks :)</p> <pre><code>&lt;?php //DEFINISCO IL CUSTOM POST TYPE TETTI add_action( 'init', 'tetti_post_type' ); function tetti_post_type() { $labels_tetti = array ( 'name' =&gt; __('Tetti'), 'singular_name' =&gt; __('Tetto'), 'add_new' =&gt; __('Aggiungi Tetto'), 'add_new_item' =&gt; __('Aggiungi Nuovo Tetto'), 'view_item' =&gt; __('Vedi Tetto') ); $args_tetti = array ( 'labels' =&gt; $labels_tetti, 'public' =&gt; true, 'publicly_querable' =&gt; true, 'show_ui' =&gt; true, 'rewrite' =&gt;true, 'menu_position' =&gt; 5 ); register_post_type ('tetti', $args_tetti); } //AGGANCIO I CAMPI PRESONALIZZATI AL CUSTOM POST TYPE TETTI add_action( 'add_meta_boxes', 'custom_field_tetti' ); function custom_field_tetti(){ add_meta_box('specifiche_tetti_meta', 'Specifiche Tetti', 'specifiche_tetti', 'tetti', 'normal', 'high' ); } function specifiche_tetti(){ global $post; $custom_seriale = get_post_custom($post-&gt;ID); $tetti_seriale = $custom_seriale['tetti_seriale'][0]; ?&gt; &lt;label&gt;Seriale:&lt;/label&gt; &lt;input type="text" id="tetti_seriale" name="tetti_seriale" value="&lt;?php echo $tetti_seriale; ?&gt;"/&gt; &lt;?php } //SALVO I CAMPI PRESONALIZZATI DEL CUSTOM POST TYPE TETTI add_action('save_post', 'save_specifiche_tetti'); global $post; function save_specifiche_tetti(){ update_post_meta($post-&gt;ID, 'tetti_seriale', $_POST['tetti_seriale']); } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload