Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'wp-load.php';
- $posts = get_posts('numberposts=-1');
- foreach ( $posts as $post ) {
- preg_match('/([0-9]*)\. (.*)/', $post->post_title, $matches);
- if ( !empty($matches) ) {
- echo "Post #{$post->ID}<br />\n";
- echo "Number: {$matches[1]}<br />\n";
- add_post_meta($post->ID, 'number', $matches[1], true);
- echo "Title: {$matches[2]}<br />\n";
- $post->post_title = $matches[2];
- wp_update_post($post);
- }
- }
- echo 'All Done!';
- ?>
Add Comment
Please, Sign In to add comment