1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do you manage thousands of posts? How to bulk delete old posts?

Discussion in 'Blogging' started by bbonds756, Jun 30, 2011.

  1. bbonds756

    bbonds756 Newbie

    Joined:
    Apr 30, 2010
    Messages:
    8
    Likes Received:
    0
    Looking for a way to delete my old autoblog posts. I have several thousand posts and would like the old ones (maybe posts that are 6 months old) to be completely removed/deleted from wordpress and the sql database. If someone visits a link for a deleted post, i would like them to be redirected back to the home page of my site. i assume a cron job of some kind would take care of this. can anyone help?
     
  2. bluemonster

    bluemonster Junior Member

    Joined:
    Jun 13, 2011
    Messages:
    106
    Likes Received:
    13
    Location:
    Adent.io
    Home Page:
    there is a wordpress plugin named 'Bulk Delete' that deletes the posts in bulk based on the categories, tags or custom taxonomies.

    If you want to try the SQL route, the following four queries should delete the posts you want to delete, plus any comments attached to them: DELETE FROM wp_commentmeta
    WHERE comment_id IN (
    SELECT comment_ID FROM wp_comments
    WHERE comment_post_ID IN (
    SELECT ID FROM wp_posts
    WHERE post_category = 9 AND post_date < '2010-01-01'));

    DELETE FROM wp_comments
    WHERE comment_post_ID IN (
    SELECT ID FROM wp_posts
    WHERE post_category = 9 AND post_date < '2010-01-01');

    DELETE FROM wp_postmeta
    WHERE post_id IN (
    SELECT ID FROM wp_posts
    WHERE post_category = 9 AND post_date < '2010-01-01');

    DELETE FROM wp_posts
    WHERE post_category = 9 AND post_date < '2010-01-01';
    This will permanently delete the relevant posts and comments. There is no recovering the data you delete this way. BACK UP YOUR DATABASE BEFORE YOU DELETE ANYTHING.

    Also use the plugin 'Redirecting error 404 to Homepage' so that all the error posts will be redirected to homepage.

    You can also try 'advanced permalink' plugin which redirects all the broken old posts to the correct new posts.
     
    • Thanks Thanks x 1
  3. heg616

    heg616 Newbie

    Joined:
    Mar 6, 2009
    Messages:
    2
    Likes Received:
    0
    yep, Bulk Delete. sometimes a little buggy for me but otherwise works great
     
  4. annabelle07

    annabelle07 Newbie

    Joined:
    Jul 2, 2011
    Messages:
    35
    Likes Received:
    1
    You can use the bulk delete plugin to delete form selected categories. The plugin can also be used to delete all drafts, revisions and pages too.
     
  5. bbonds756

    bbonds756 Newbie

    Joined:
    Apr 30, 2010
    Messages:
    8
    Likes Received:
    0
    So each one of these four sql queries will delete posts older than a certain date? Should i be running this through phpmyadmin?

     
  6. sircoldfire

    sircoldfire Junior Member

    Joined:
    Jul 2, 2011
    Messages:
    104
    Likes Received:
    27
    Occupation:
    motha fu¬Ękin hu$tla
    Location:
    bank teller window cashin checks
    no!!!!!! big^G with wtfpwn your a$s ... keep the pages ... buy a bigger host if you have to but you do not want to delete them .... also more pages = more stuff for incoming searches ... so dont delete them ...
     
  7. chrisnkay

    chrisnkay Junior Member

    Joined:
    Apr 5, 2010
    Messages:
    115
    Likes Received:
    17
    I used a plugin called blog pig or nuke pig or something like that. It worked really well to bulk delete and different things like that.
     
  8. bbonds756

    bbonds756 Newbie

    Joined:
    Apr 30, 2010
    Messages:
    8
    Likes Received:
    0
    the problem is i think my database is corrupted at a certain date (previously i had ran a mysql query that didnt delete all posts correctly now im seeing problems like post comments that cant be deleted, or it showing i have 4 new comments when in fact its about 20) therefore i would like to run an sql query to delete all posts and associated data from a certain date.
     
  9. bbonds756

    bbonds756 Newbie

    Joined:
    Apr 30, 2010
    Messages:
    8
    Likes Received:
    0

    Can someone help me combine the above suggested SQL queries with the following query so i can delete all posts that are a certain number of days old instead of older than a certain date?

    DELETE FROM `wp_posts`
    WHERE `post_type` = ?post?
    AND DATEDIFF(NOW(), `post_date`) > X
     
  10. paulcarter97

    paulcarter97 Regular Member

    Joined:
    Nov 27, 2011
    Messages:
    392
    Likes Received:
    37
    Why would you want to delete the old one ? Is there any harm letting it there ?
     
  11. markhenry121

    markhenry121 Elite Member

    Joined:
    Oct 14, 2011
    Messages:
    2,149
    Likes Received:
    239
    You are having any problem with the old post then why don't you leave as it is.
     
  12. CyberSEO

    CyberSEO Senior Member

    Joined:
    Jul 14, 2011
    Messages:
    939
    Likes Received:
    256
    Occupation:
    programmer
    Home Page:
    WP Mass Delete is what you're looking for.