November 14, 2012
No Comments
Be careful to do this to make data searchable. Out of the box WPAlchemy uses WPALCHEMY_MODE_ARRAY which is not very useful for meta searches!
$custom_metabox = new WPAlchemy_MetaBox(array
(
'id' => '_custom_meta',
'title' => 'My Custom Meta',
'template' => TEMPLATEPATH . '/custom/meta.php',
'mode' => WPALCHEMY_MODE_EXTRACT,
'prefix' => '_my_'
));
If you forget, use this:
if ( ! function_exists( 'msd_convert_storage' ) ) :
function msd_convert_storage($key,$prefix,$posttype) {
$args = array(
'numberposts' => -1,
'post_type' => $posttype,
);
$items = get_posts($args);
foreach($items AS $item){
$the_meta = get_post_meta($item->ID,$key);
$fields = array();
foreach($the_meta[0] AS $meta_key => $meta_value){
$meta_key = $prefix.$meta_key;
update_post_meta($item->ID, $meta_key, $meta_value);
$fields[] = $meta_key;
}
update_post_meta($item->ID,$key.'_fields',$fields);
delete_post_meta($item->ID,$key);
}
}
endif;