Regenerate Slugs From Title of Posts. Yes, it is possible. Sample code, has to be tested and refined:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // get all posts $posts = get_posts( array ( 'numberposts' => -1 ) ); foreach ( $posts as $post ) { // check the slug and run an update if necessary $new_slug = sanitize_title( $post->post_title ); if ( $post->post_name != $new_slug ) { wp_update_post( array ( 'ID' => $post->ID, 'post_name' => $new_slug ) ); } } |
I just made this up, there are probably some errors and egde cases, but it should give you an idea. Also, this may take a while, so it could be useful to split the update into smaller chunks.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.