Created
November 13, 2013 00:12
-
-
Save mustafauysal/7441174 to your computer and use it in GitHub Desktop.
Bulk Fixing WordPress Duplicated Posts! Read for more information: http://uysalmustafa.com/2013/11/13/bulk-fixing-wordpress-duplicated-posts/
This file contains 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 | |
require( 'wp-load.php' ); | |
//set_time_limit(30000); // you can set time limit, but I prefer to use command line > php fix-duplicated-posts.php | |
$query = "SELECT id,post_name, Count(*) FROM wp_posts WHERE post_type = 'post' GROUP BY post_name HAVING Count(*) > 1"; | |
$duplicated_posts = $wpdb->get_results( $query ); | |
foreach ( $duplicated_posts as $result ) { | |
$prepost = get_post($result->id); | |
$prepost->post_name = ''; | |
wp_update_post( $prepost ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment