Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'wp-load.php';
- echo "Regenerating post slugs...<br />\n";
- $posts = $wpdb->get_results( "SELECT ID, post_title, post_name FROM {$wpdb->posts} WHERE post_status = 'publish'" );
- foreach ( (array) $posts as $post ) {
- $post_name = sanitize_title( $post->post_title );
- if ( $post_name !== $post->post_name ) {
- add_post_meta( $post->ID, '_wp_old_slug', $post->post_name );
- $wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ), array( 'ID' => $post->ID ) );
- }
- }
- echo 'All done!';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement