Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bulk Fixing WordPress Duplicated Posts! Read for more information: http://uysalmustafa.com/2013/11/13/bulk-fixing-wordpress-duplicated-posts/
<?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
You can’t perform that action at this time.