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]{4})/', $post->post_title, $matches);
- if ( !empty($matches) ) {
- echo "Post #{$post->ID}<br />\n";
- echo "Title: {$matches[1]}<br />\n";
- $post->post_title = $matches[1];
- wp_update_post($post);
- echo "Year: {$matches[2]}<br />\n";
- add_post_meta($post->ID, 'year', $matches[2], true);
- }
- }
- echo 'All Done!';
- ?>
Add Comment
Please, Sign In to add comment