I've added a custom post type, which is working great; I've also added two metaboxes, which appear to work well, but the content in them always disappears after a few minutes.
If anyone could help out on this I would be eternally grateful, S.
//meta box code//
add_action( 'admin_init', 'add_custom_metabox' );
add_action( 'save_post', 'save_custom_details' );
function add_custom_metabox() {
add_meta_box( 'custom-metabox', __( 'Product Description & Ingredients' ), 'descr_custom_metabox', 'sorbets', 'normal', 'low' );
}
function descr_custom_metabox() {
global $post;
$proddescr = get_post_meta( $post->ID, 'proddescr', true );
$ingredients = get_post_meta( $post->ID, 'ingredients', true );
?>
<p><label for="proddescr">Product Description:<br />
<textarea id="proddescr" name="proddescr" style="margin:0;height:7em;width:98%;" cols="45" rows="4"><?php if( $proddescr ) { echo $proddescr; } ?></textarea></label></p>
<p><label for="ingredients">Ingredients:<br />
<textarea id="ingredients" name="ingredients" style="margin:0;height:7em;width:98%;" cols="45" rows="4"><?php if( $ingredients ) { echo $ingredients; } ?></textarea></label></p>
<?php
}
function save_custom_details( $post_ID ) {
global $post;
if( $_POST ) {
update_post_meta( $post->ID, 'proddescr', $_POST['proddescr'] );
update_post_meta( $post->ID, 'ingredients', $_POST['ingredients'] );
}
}
function get_descr_ingred_box() {
global $post;
$proddescr = get_post_meta( $post->ID, 'proddescr', true );
$ingredients = get_post_meta( $post->ID, 'ingredients', true );
return array( $proddescr, $ingredients );
}