• Is there an easy way to batch-delete a lot of old posts? I mean, a LOT – like, upwards of 40,000.

    They’re all in a single category, and we want to be able to remove all of them before a certain date (i.e. keep the newest ones).

    I see that there’s a batch-delete plugin, but the reviews of it have me scared. Is there another way?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The only other way to do it is to use a tool like phpMyAdmin and run a custom query on your WP database. But that’s even scarier unless you know what you’re doing.

    If you want to try it, give me the category and cutoff date, and I’ll give you the query you would need to run.

    Thread Starter jbickers

    (@jbickers)

    You’re kind to offer – the category is 7, and we want to get rid of everything before 1/1/10.

    (Also, if you could tell me where in phpmyadmin to go to execute it, that’d be helpful – I have access but am unfamiliar with the interface.)

    Here you go. As for where to execute this in phpMyAdmin, I can’t help you with that, as I don’t use it myself (I always run mysql from the command line).

    *** WARNING *** Use at your own risk. Make a backup of your database first. THERE IS NO UNDO.

    DELETE a,b,c
    FROM wp_posts a
    LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id)
    LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
    LEFT JOIN wp_term_taxonomy d ON ( b.term_taxonomy_id = d.term_taxonomy_id)
    WHERE a.post_date < '2010-01-01 00:00:00'
    AND d.taxonomy = 'category'
    AND d.term_id = 7;
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Batch-deleting old posts?’ is closed to new replies.