Remove Duplicate Posts in WordPress
Below is the SQL script that will attempt to identify and remove duplicate posts in your WordPress database. This script can be useful for autoblogging. If you use plugins like WP-o-Matic to pull full-text RSS feeds into your database, you will inevitably end up with a bunch of duplicate articles. This is not good as many search engines – including Google – frown upon duplicate content and may decide not to index much of your site.
Edit the script and add your database information. You may need to change “wp_posts” to “_posts”. Before using the script, backup your database. There is no “undo” button in the script. If you are happy with the result, set up a cron job to run the script twice every day. Keep in mind that the script is looking for duplicate post titles. It does not look at the actual post content. Do not use this script if you purposefully have different posts with the same title.
#!/bin/ksh MYSQL=/usr/bin/mysql DBUSER=your_db_username DBPASS=your_db_password DBNAME=db_name $MYSQL -u$DBUSER -p$DBPASS $DBNAME < 1 ) as good_rows on good_rows.post_title = bad_rows.post_title and good_rows.min_id bad_rows.id ; EOF