Error saving custom meta boxes data
-
Hi, people. I’m starting wordpress plugin’s development and this is my first attempt to make one. I have a problem with saving custom meta boxes data. I can see te meta bo in my pages but when i save post i get an internal server error. Can someone please tell me why? Thanks
<?php /* Plugin Name: nw_Page_Gallery */ class NW_mb{ var $post_meta = array("image1","image2"); var $boxes = array(); public function __construct(){ } public function add_Box(){ add_meta_box("nw_meta_box","Sfondo pagina",array($this, 'add_html'),"page"); } public function add_Html($post){ $post_meta = get_post_meta($post->ID, "nw_meta_boxes"); print_r($post->ID); ?> <label>Indirizzo immagine</label> <input type="text" id="nw_image1" name="nw_image1" value="<?php echo $this->post_meta[0] ?>" /> <label>Indirizzo immagine</label> <input type="text" id="nw_image2" name="nw_image2" value="<?php echo $this->post_meta[1] ?>" /> <label>Indirizzo immagine</label> <input type="text" id="nw_image3" name="nw_image3" value="<?php echo $this->post_meta[2] ?>" /> <label>Indirizzo immagine</label> <input type="text" id="nw_image4" name="nw_image4" value="<?php echo $this->post_meta[3] ?>" /> <label>Indirizzo immagine</label> <input type="text" id="nw_image5" name="nw_image5" value="<?php echo $this->post_meta[4] ?>" /> <? } public function save_Box($id){ update_post_meta($id, 'nw_meta_boxes', array( $_POST['nw_image1'], $_POST['nw_image2'], $_POST['nw_image3'], $_POST['nw_image4'], $_POST['nw_image5'] )); } } add_action("add_meta_boxes", function(){ $meta = new NW_mb(); $meta->add_Box(); }); add_action("save_post", function(){ $meta->save_Box(); });
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘Error saving custom meta boxes data’ is closed to new replies.