Title: remove duplicate posts
Last modified: August 18, 2016

---

# remove duplicate posts

 *  [josh80](https://wordpress.org/support/users/josh80/)
 * (@josh80)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/remove-duplicate-posts/)
 * I used wp-o-matic, and it made several hundred duplicate posts…How do I remove
   all of those?

Viewing 14 replies - 1 through 14 (of 14 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/remove-duplicate-posts/#post-655354)
 * It’s slow, it’s ugly, it’s boring, but I’d backup the database and then delete
   each one in Manage->Posts.
 * [WordPress Backups](http://codex.wordpress.org/WordPress_Backups)
 *  [exntrick](https://wordpress.org/support/users/exntrick/)
 * (@exntrick)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/remove-duplicate-posts/#post-655603)
 * I had the same problem.
 * Use this it only deleted the dupes. To be on the safe side you should run it 
   as a select first. AND back up your DB
 * 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 
   <> bad_rows.id
 *  [warner444](https://wordpress.org/support/users/warner444/)
 * (@warner444)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/remove-duplicate-posts/#post-655624)
 * How and where do you run this script?
 *  [Lars Koudal](https://wordpress.org/support/users/lkoudal/)
 * (@lkoudal)
 * [18 years ago](https://wordpress.org/support/topic/remove-duplicate-posts/#post-655677)
 * Warner: You need to log in to your mysql database (usually PHPMyAdmin) and then
   run that script there. I just used it on a site of mine where a script had went
   totally overboard and added about 93.000 duplicate posts!
 * Thank you for the tip, exntrick, it really saved me! 🙂
 *  [charissaproctor](https://wordpress.org/support/users/charissaproctor/)
 * (@charissaproctor)
 * [18 years ago](https://wordpress.org/support/topic/remove-duplicate-posts/#post-655682)
 * How do you run this script once you are in mysql? Is it under query?
 *  [charissaproctor](https://wordpress.org/support/users/charissaproctor/)
 * (@charissaproctor)
 * [18 years ago](https://wordpress.org/support/topic/remove-duplicate-posts/#post-655683)
 * I ran this script, but my duplicates are still there?
    Anyone have any ideas 
   about removing? When I got into mysql database, there are not duplicate entries,
   but the front page shows duplicates down at the bottom, for just some of the 
   posts, but the posts don’t seem to have a core idenitfying characteristic, ie.
   symbols in post title, flash media in post, etc.
 *  [abelcreative](https://wordpress.org/support/users/abelcreative/)
 * (@abelcreative)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/remove-duplicate-posts/#post-655686)
 * script worked great for me (also note, for WP 2.5 users, you need to add:
 * `return 0;` after `if ($post_name_check || in_array($post_name, $wp_rewrite->
   feeds) ) {` on line 1284 of wp-includes/post.php to get the duplicate posts to
   stop.
 * However, after running the above script, my category count in the sidebar is 
   still reflecting the old, bloated count (using show_count=1). If I go to the 
   manage screen in the admin mode, the count is correct, but not on the live site.
   Any clue why this would be happening??
 *  [charissaproctor](https://wordpress.org/support/users/charissaproctor/)
 * (@charissaproctor)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/remove-duplicate-posts/#post-655687)
 * thanks…for some reason, I have run that script as well as adding the return 0,
   but still have the dups at the bottom of my page….
 *  [charissaproctor](https://wordpress.org/support/users/charissaproctor/)
 * (@charissaproctor)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/remove-duplicate-posts/#post-655688)
 * if ($post_name_check || in_array($post_name, $wp_rewrite->feeds) ) return 0; {
   
   $suffix = 2; do { $alt_post_name = substr($post_name, 0, 200-(strlen($suffix)
   +1)). “-$suffix”; // expected_slashed ($alt_post_name, $post_name, $post_type)
   $post_name_check = $wpdb->get_var($wpdb->prepare(“SELECT post_name FROM $wpdb-
   >posts WHERE post_name = ‘$alt_post_name’ AND post_type = ‘$post_type’ AND ID!
   = %d AND post_parent = %d LIMIT 1”, $post_ID, $post_parent));
 * maybe I entered it in the wrong format?
 *  [MissDanni](https://wordpress.org/support/users/missdanni/)
 * (@missdanni)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/remove-duplicate-posts/#post-655690)
 * Replace `$suffix = 2`
    With `return 0;`
 * You will find `$suffix = 2` twice in wp-includes/post.php
 *  [charissaproctor](https://wordpress.org/support/users/charissaproctor/)
 * (@charissaproctor)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/remove-duplicate-posts/#post-655691)
 * thanks!
 *  [charissaproctor](https://wordpress.org/support/users/charissaproctor/)
 * (@charissaproctor)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/remove-duplicate-posts/#post-655696)
 * still does not work for me?
    [http://surfboard-reviews.com](http://surfboard-reviews.com)
 *  [screamingsilence](https://wordpress.org/support/users/screamingsilence/)
 * (@screamingsilence)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/remove-duplicate-posts/#post-655699)
 * with worked great 10x to everyone…..
    i was getting duplicate post whenever i
   tried to import my post from blogger…this solved my problem 10x again. 🙂
 *  [intopuddles](https://wordpress.org/support/users/intopuddles/)
 * (@intopuddles)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/remove-duplicate-posts/#post-655701)
 * I ran this script, but lots of posts that weren’t even duplicates were deleted.
   When I try to import my posts again, lots of them aren’t included, and I’m guessing
   it’s because of this query I ran. What do I do now?

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘remove duplicate posts’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 14 replies
 * 10 participants
 * Last reply from: [intopuddles](https://wordpress.org/support/users/intopuddles/)
 * Last activity: [17 years, 8 months ago](https://wordpress.org/support/topic/remove-duplicate-posts/#post-655701)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
