remove duplicate posts
-
I used wp-o-matic, and it made several hundred duplicate posts…How do I remove all of those?
-
It’s slow, it’s ugly, it’s boring, but I’d backup the database and then delete each one in Manage->Posts.
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.idHow and where do you run this script?
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! 🙂
How do you run this script once you are in mysql? Is it under query?
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.script worked great for me (also note, for WP 2.5 users, you need to add:
return 0;
afterif ($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??
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….
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?
Replace
$suffix = 2
Withreturn 0;
You will find
$suffix = 2
twice in wp-includes/post.phpthanks!
still does not work for me?
http://surfboard-reviews.comwith 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. 🙂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?
- The topic ‘remove duplicate posts’ is closed to new replies.