Created
February 16, 2016 21:54
-
-
Save Antoinebr/ab38f8068747fdec9516 to your computer and use it in GitHub Desktop.
wp-regenerate-slug.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $posts = get_posts(array( | |
| 'post_type' => 'page', | |
| 'post_status' => 'publish', | |
| 'orderby' => 'menu_order', | |
| 'numberposts' => 999999 | |
| )); | |
| foreach ( $posts as $post ) | |
| { | |
| $new_slug = sanitize_title( $post->post_title ); | |
| if ( $post->post_name != $new_slug ) | |
| { | |
| wp_update_post( | |
| array ( | |
| 'ID' => $post->ID, | |
| 'post_name' => $new_slug | |
| ) | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment