daily pastebin goal
69%
SHARE
TWEET

Storage Mode Converter

msd_lab Jun 23rd, 2012 378 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if ( ! function_exists( 'msd_convert_storage' ) ) :
  2.         function msd_convert_storage($key,$prefix,$posttype) {
  3.                 $args = array(
  4.                     'numberposts'     => -1,
  5.                     'post_type'       => $posttype,
  6.                 );
  7.                 $items = get_posts($args);
  8.                 foreach($items AS $item){
  9.                         $the_meta = get_post_meta($item->ID,$key);
  10.                         $fields = array();
  11.                         foreach($the_meta[0] AS $meta_key => $meta_value){
  12.                                 $meta_key = $prefix.$meta_key;
  13.                                 update_post_meta($item->ID, $meta_key, $meta_value);
  14.                                 $fields[] = $meta_key;
  15.                         }
  16.                         update_post_meta($item->ID,$key.'_fields',$fields);
  17.                         delete_post_meta($item->ID,$key);
  18.                 }
  19.         }
  20. endif;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top