Forums

remove duplicate posts (15 posts)

  1. josh80
    Member
    Posted 1 year ago #

    I used wp-o-matic, and it made several hundred duplicate posts...How do I remove all of those?

  2. MichaelH
    Moderator
    Posted 1 year ago #

    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

  3. exntrick
    Member
    Posted 11 months ago #

    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

  4. warner444
    Member
    Posted 10 months ago #

    How and where do you run this script?

  5. lkoudal
    Member
    Posted 7 months ago #

    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! :-)

  6. charissaproctor
    Member
    Posted 6 months ago #

    How do you run this script once you are in mysql? Is it under query?

  7. charissaproctor
    Member
    Posted 6 months ago #

    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.

  8. abelcreative
    Member
    Posted 5 months ago #

    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??

  9. charissaproctor
    Member
    Posted 5 months ago #

    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....

  10. charissaproctor
    Member
    Posted 5 months ago #

    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?

  11. MissDanni
    Member
    Posted 4 months ago #

    Replace $suffix = 2
    With return 0;

    You will find $suffix = 2 twice in wp-includes/post.php

  12. charissaproctor
    Member
    Posted 4 months ago #

    thanks!

  13. charissaproctor
    Member
    Posted 3 months ago #

    still does not work for me?
    http://surfboard-reviews.com

  14. screamingsilence
    Member
    Posted 2 months ago #

    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. :-)

  15. intopuddles
    Member
    Posted 2 months ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags