I am trying to create a custom post type with custom metabox array. How can I create this kind a automatic populating post type? I think I have to use two dimension array. But how can I automatically populate my data array? And how can I save this kind array.
Could some one point me to right direction?
Please take a look at the images.
Second img
My code so far :
<?php
//add custom field - price
add_action("admin_init", "price");
function object_init(){
add_meta_box("price_meta", "Price fields :", "object", "price_meta", "normal", "low");
}
function price_meta(){
global $post;
$custom = get_post_custom($post->ID);
$price = $custom["price"][0];
?>
<p style="float:left;"><label>Nr :</label><br />
<input type="text" name="priceNr" size="10" value="<?php echo $price; ?>"/>
</p>
<p style="float:left;"><label>Description :</label><br />
<input type="text" name="priceD" size="50" value="<?php echo $price; ?>"/>
</p>
<p style="float:left;"><label>Price :</label><br />
<input type="text" name="price" size="20" value="<?php echo $price; ?>"/>
</p>
<?php
}
//Save product price
add_action('save_post', 'save_detailss');
function save_detailss(){
global $post;
$post_id = $post->ID;
// to prevent metadata or custom fields from disappearing...
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
return $post_id;
update_post_meta($post_id, "price", $_POST["price"]);
}
?>
Your code make no sense, anyway here is a nice way to do it and you get:
I keep getting people asking me how to get the data to print in the fronend so: