How to delete duplicate Wordpress posts

It can also used to delete the duplicate posts by wp-o-matic

I recently ran into trouble with a Wordpress installation of mine, where a homemade script went totally overboard, and never stopped running, adding posts to the database. Over a few days it added close to 9.000 posts, of which all were duplicates.
After a bit of searching I found the problem, but getting into the database to clean up was a bit of a problem, since the script was still running. I had to remove the script totally from my install in order to stop it!

After a bit of google search i found this trick its working 100% i tried with wordpress 2.6

login in to your  cpanel and go to the phpmyadmin  and select the your wordpress database and run this script in the  query window

DELETE bad_rows.*
from wp_posts as bad_rows
inner join (
select post_title, MIN(id) as min_id
from wp_posts
group by post_title
having count(*) > 1
) as good_rows on good_rows.post_title = bad_rows.post_title
and good_rows.min_id <>
after deleting the posts u can  prevent the  duplicate post by Wp-o-matic
  1. Open up wp-includes/post.php in your favorite editor
  2. at approx line 703 you will find the following line :
    if ($post_name_check || in_array($post_name, $wp_rewrite->feeds) ) {
  3. After this insert a new line of code :
    return 0;
  4. save (you did make a backup, right?).
  5. All done.

Article written by AUTHOR_NAME