I have a custom post type which is working fine, however the meta box does isn't saving.
Long & short, i'm stumped!
add_action('init', 'portfolio');
function portfolio() {
$args = array(
'label' => __('Portfolio'),
'singular_label' => __('Portfolio'),
'public' => true,
'show_ui' => true,
'menu_position' => 5,
'capability_type' => 'page',
'hierarchical' => false,
'rewrite' => true,
'show_in_nav_menus' => true,
'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),
'has_archive' => true
);
register_taxonomy( 'type', 'portfolio',
array(
'hierarchical' => false,
'label' => __('Project Type'),
'query_var' => 'type',
'rewrite' => array('slug' => 'portfolio/type' )
)
);
register_post_type( 'portfolio' , $args );
}
add_action("admin_init", "admin_init");
add_action('save_post', 'save_meta_data');
function admin_init(){
add_meta_box("portfolio_text", "Main Text", "portfolio_options", "portfolio", "normal", "high");
}
/* Meta Values for Shorts */
function portfolio_options() {
global $post;
$custom = get_post_custom($post->ID);
$short_embed = $custom["portfolio_text"][0]; ?>
<textarea name="portfolio_text" cols="40" rows="1" style="width:98%; height:100px"/><?php echo get_option('portfolio_text'); ?></textarea>
<?php }
/* Save Changes */
function save_meta_data($ID = false, $post = false) {
if($post->post_type != 'portfolio')
return;
update_post_meta($ID, 'portfolio_text', $_POST['portfolio_text']);
}
Your help is appreciated!
Cheers, George