SergeyBiryukov

Sergey Biryukov

Jan 21st, 2011
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?php
  2. include 'wp-load.php';
  3. $posts = get_posts('numberposts=-1');
  4. foreach ( $posts as $post ) {
  5.     preg_match('/([0-9]*)\. (.*)/', $post->post_title, $matches);
  6.     if ( !empty($matches) ) {
  7.         echo "Post #{$post->ID}<br />\n";
  8.  
  9.         echo "Number: {$matches[1]}<br />\n";
  10.         add_post_meta($post->ID, 'number', $matches[1], true);
  11.  
  12.         echo "Title: {$matches[2]}<br />\n";
  13.         $post->post_title = $matches[2];
  14.         wp_update_post($post);
  15.     }
  16. }
  17. echo 'All Done!';
  18. ?>
Add Comment
Please, Sign In to add comment