I’ve got a custom post type curiculum
and a metabox that saves a value to a custom field. However this custom field is added to another custom post type (created by an e-commerce plugin) wpsc-product
.
This is a snippet of the code that deals with the metabox. The question is, how to prevent the custom field being added to the wpsc-product
?
/* Curiculum Date Metabox */
function curiculum_date_fields() {
if ( get_post_type() == 'curiculum'):
global $post;
$custom = get_post_custom( $post->ID );
$curiculum_date_from = $custom["curiculum_date_from"][0];
?>
<p>
<label for="curiculum_date_from">Date:</label><br />
<input size="32" type="text" name="curiculum_date_from" id="curiculum_date_from" value="<?php echo $curiculum_date_from; ?>" />
<?php
endif;
}
function add_curiculum_date_box() {
add_meta_box("curiculum_date_info", "Event Date", "curiculum_date_fields", "curiculum", "side");
}
function save_curiculum_date() {
global $post;
update_post_meta($post->ID, "curiculum_date_from", $_POST["curiculum_date_from"]);
}
add_action('admin_init', 'add_curiculum_date_box');
add_action('save_post', 'save_curiculum_date');
add_action('publish_post', 'save_curiculum_date');
EDIT: Code for the curiculum
custom post type:
add_action('init', 'curiculum_register');
function curiculum_register() {
$labels = array(
'name' => _x('CV Events', 'post type general name'),
'singular_name' => _x('CV Event', 'post type singular name'),
'add_new' => _x('Add New', 'testimonials item'),
'add_new_item' => __('Add New Event'),
'edit_item' => __('Edit Event'),
'new_item' => __('New Event'),
'view_item' => __('View Event'),
'search_items' => __('Search Events'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 7,
'exclude_from_search' => true,
'supports' => array('title','editor', 'custom-fields')
);
register_post_type( 'curiculum' , $args );
}