Bulk Delete WordPress Plugin

Bulk Delete WordPress Plugin

Bulk Delete is a WordPress Plugin which can be used to delete posts in bulk from selected categories or tags. This Plugin can also delete all drafts, post revisions or pages.

Download

You can download the Plugin as a zip file from the WordPress official Plugin directory.

Installation

Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation and then activate the Plugin from Plugins page.

Screenshot

Bulk Delete WordPress Plugin

Feedback

If you have any comments or if you want to report any bugs, please leave a comment below or contact me.

History

  • 2009-02-02 – v0.1 – Initial version
  • 2009-02-03 – v0.2 – Second release – Fixed issues with pagging
  • 2009-04-05 – v0.3 – Third release – Prevented drafts from deleted when only posts are selected
  • 2009-07-05 – v0.4 – Added option to delete by date.
  • 2009-07-21 – v0.5 – Fifth release – Added option to delete all pending posts.
  • 2009-07-22 – v0.6 – Sixth release – Added option to delete all scheduled posts.

Share thy love

106 Comments so far

Trackback URI | Follow up comments through RSS Feed | Post a comment

  • Maximus says:

    Hi,
    Thanks for this plugin. But I get this error while using it. When I tried to delete the posts in a category it pops me with the question that “Select atleast one category” eventhough I have selected the categories.

    Thanks!

    • Sudar says:

      @Maximus,

      Thanks for trying out my Plugin.

      Let me know in which browser and in WordPress version you are getting this error, so that I will try to fix it.

  • Vavai says:

    Thanks, it’s suitable with my purpose. Awesome plugin.

  • scott says:

    You sir are a genius!!!!

    This is a great Plugin

    Thanks

  • Onreviews says:

    still delete published post from draft (published post is always recognize as draft)

  • Lynn says:

    This saved me a great deal of work, thank you. Is there a way of adapting it to bulk delete posts that are in Pending Review?

    • Sudar says:

      @Lynn,

      Nice to know that this Plugin was of help to you. Right now it is not possible to delete posts pending for review. However I will add this feature when I find some time.

  • Wayne says:

    Nice plugin, works very well. How about coming up with a bulk tag remover?

    Thanks.

    • Sudar says:

      @Wayne,

      Nice to know that you like the Plugin and thanks for suggesting bulk tag remover. I will implement it when I find some time. :)

  • This is a great plug-in, and it seems to work fine in a test WordPress 2.7.1 installation I tried it out on.

    Does anyone know of a recent plug-in that will delete posts in a specified category after a certain interval (say, over 90 or 180 days old) … that works in 2.7.1??

    Thanks for sharing this code!

    Robin

    • Sudar says:

      @Robin,

      I am not sure if there is a Plugin to do that. I will try to add that feature to this Plugin if I get some free time.

    • Sudar says:

      @Robin,

      I have updated the Plugin and have added the support for filter by date range. This feature is available from v0.4 and above. Try it out and let me know if you have any feedback.

  • Merci says:

    Hi Sudar! I tried your plug-in today and it worked almost perfectly. The only problem is, that it does not delete the category that has 1234 posts. It starts to proceed, but after 2 seconds the page turns blank and nothing happens. Do you have an idea why, is there a limit or what do you think I should do?

    • Sudar says:

      @Merci,

      I havn’t placed any limit on the number of posts that can be deleted in the Plugin code.

      My guess is that the PHP script is timing out. Try to increase the timeout limit in your php.ini file.

      Let me know whether it works after increasing the timeout.

  • Merci says:

    I did not try what you suggested, because I started to delete the posts manually and when there were less than 1000, I tried to bulk delete again and than it worked. Thanks anyway, your plug-in really helped a lot :)

  • Rob Barham says:

    Thanks for this plugin, worked like a dream and saved me a lot of time.

  • Mark says:

    I’m trying you’re plugin on a Wordpress 2.7.1 install and trying to delete posts by cartegory but I seem to have bit hit by a problem another of you’re commenters have said. I can’t delete posts in a category with over 1000 posts. I was able to delete posts in a category of 518 posts and 18 posts.

    But I have one category I want to clear out and it contains 6359 posts, as task I don’t want to do by hand. When I click delete, nothing happens. It just pulls up a blank page. It doesn’t look like a timeout because it doesn’t seem to do anything, unlike when you do delete successfully, where the page takes a few seconds to load.

    • Sudar says:

      @Mark,

      Thanks for reporting the issue. I have tested it with only around 1000 posts before. I will try to see how it behaves when the number of posts is huge and will let you know if I fix the issue.

  • Mark says:

    BTW You’re RSS feed linked to by the “Subscribe to the comments through RSS Feed” is broken. It seems to contain your blogs posts instead of comments on this post!

  • Mark says:

    I did some digging and it looks like WP_Query breaks down if you try to query a category with more than 1000 posts and ‘nopaging’ enabled. I couldn’t find any useful info in my error logs. It just freezes. I’ve increased the PHP timeout and memory access too, but no affect.

    So I did a little hack that seems to work, deleting the posts in pages. It does time out so you have to run it several times. But saves me a good hour or two of tedious manual clicking…


    case "bulk-delete-cats":
    // delete by cats
    $selected_cats = $_POST['smbd_cats'];

    /*$posts = $wp_query->query(array('category__in'=>$selected_cats,'post_status'=>'publish', 'post_type'=>'post', 'nopaging'=>'true'));
    foreach ($posts as $post) {
    wp_delete_post($post->ID);
    }*/

    // if you have more than 1000 entries in a category,
    // querying them with nopaging breaks WP

    $posts = $wp_query->query(array('category__in'=>$selected_cats,
    'post_status'=>'publish',
    'post_type'=>'post'));
    while($posts) {
    foreach ($posts as $post) {
    wp_delete_post($post->ID);
    }
    $posts = $wp_query->query(array('category__in'=>$selected_cats,
    'post_status'=>'publish',
    'post_type'=>'post'));
    }

    break;

    It’s a pity you have to run the post to delete through wp_delete_posts because this creates many queries for each post. If you could delete the posts in one query and then tidy up, I think it’d be a lot more efficient and I wouldn’t hit the timeout.

    • Sudar says:

      @Mark,

      The reason why I am running each post through wp_delete_posts is that, only this function deletes all references of the posts like attachements, comments etc. Let me see if I can reduce the amount of query so as that it doesn’t timeout.

  • Alex says:

    Hi,

    I’ve read some of you had a problem with categories with more than 1.000 posts in it. In these cases the script simply shows a white, empty page. Thats it… *grmpf*

    I think I got a workaround, at least for those who have control over their server.

    I tried to increase the PHP.INI max_execution_time as mentioned before, but that alone did not work.

    In my case with a category with approx. 5.800 posts it worked with the following settings:

    max_execution_time = 600 ; Maximum execution time of each script, in seconds
    max_input_time = 30; Maximum amount of time each script may spend parsing request data
    memory_limit = 256M ; Maximum amount of memory a script may consume (8MB)

    I think you need to increase both max_execution_time and memory_limit, even if these values are far too high for normal usage, dont forget to set to the initial values after the deletion is done!

    Greetz
    Alex

  • Sidney says:

    I’m testing this on a 2.8 installation and it seems to be working great.

    Like Robin, I also need the ability to delete posts that are older than say, 15 or 30 days. This would be a great feature.

    • Sudar says:

      @Sidney,

      I have added this feature to the Pluing. It is available from v0.4 and above. Try it out and let me know if you have any feedback.

  • Alb3rt1 says:

    Hi I tested last version 0.4 on wp2.7 and seems doesn’t works….

    • Sudar says:

      @Alb3rt1,

      0.4 is meant for WordPress 2.8+ Can you try it in WordPress 2.8+

      Also let me know what was the issue that you were facing.

  • John says:

    Is it possible to add scheduled posts to a future update.

    Having added a number of posts to my schedules list I realise they are not relevant and would like to remove them along with similar posts that have already posted.

    Thanks

    • Sudar says:

      @John,

      I am working on adding an option to select future posts. It’s in the final stages and I will release the future by tomorrow. So stay tuned :)

    • Sudar says:

      @John,

      v0.6 of the Plugin supports deleting future posts in bulk. Check it out and let em know how it works for you.

  • privendo says:

    can you add also a feature to delete duplicate posts and make it working via cron?

  • John says:

    Just downloaded the plugin and wiped uot a months worth of scheduled post!

    Excellent work, thank you.

  • @Sudar : Thanks for including the new features in 0.6… Unfortunately, I get the same blank page issue when running it against a category that has a huge amount of posts (> 20,000) … I wonder if I should adjust the php.ini settings (temporarily) to higher values temporarily to let your plugin run.

    Thanks for sharing your work. :)

    Robin

    • Sudar says:

      @Robin,

      I am thinking of doing the delete in batches so as to prevent the script from timing out. Will implement it when I get some free time.

  • John says:

    Would be interested to know if there is a max limit for deletions as this was an issue my partner raised about bulk deletions. Not just the php.ini settings but also about the string length generater to call the deletions. Does the plug in run in batches?

  • John says:

    Just run the plug in on separate blog with great success.

    I am sure it would require completely different programming but could you select posts based on say, single words or two word phrases? This would help select posts that are mixed in with others and not easily identifiable by category.

    I know this is very different reqiurement but it would be useful for removing post featuring say a Trade Name or brand where a dispute happens.

    Thanks anyway

  • John says:

    What is the earliest version of wordpress that this plug in will work with?

    I just tried it on an older blog and it failed

    Thanks

    • Sudar says:

      @John,

      I don’t normally test my Plugins in older version of WordPress, but technically it should work in 2.5 and above.

      In which version you are getting the error and if possible specify the error. I will see if I can make it backward compatible.

  • John says:

    That’s my problem, they have been stripped out so I can’t see which version they are.

    Any tell tales signs or coding notes that might identify them?

  • Mike says:

    Any update on the automation process you mentioned in a post back in May? In other words, presetting the plugin to run a predetermined deletion process at a predetermined timeframe.

    Thanks

    • Sudar says:

      @Mike,

      It is still in my todo list ;)

      I faced some problem in scheduling code and left it there. I will dust off the code and will update it when I get some free time.

  • Sarah Jo says:

    Just installed this plugin, and I’m hoping it will work for me, but it’s not working right now. When I go to the Bulk Delete page, there’s nothing below the Warning tag. No categories to choose, no buttons to click. I’ve installed, deleted, and reinstalled the plugin multiple times, and no luck. Thoughts?

  • Peter says:

    Thanks for the great plugin.

    1) It would be great if this plugin can be scheduled to auto delete posts (via cron or something).

    2) Another useful feature would be to remove posts containing/not containing a particular keyword.

    Eg. Delete all posts whose title/post contains “flower”

    or Delete all posts whose title/post does not contain “flower”.

    • Sudar says:

      @Peter,

      Thanks for your suggestions. Both of them are there in my todo list and I will try to implement them when I get some free time.

  • Sarah says:

    I’m using 2.8.3, and I realize that this plugin only works up to 2.8.2. Any plans to update it?

    • Sudar says:

      @Sarah,

      There are no compatibility issues between 2.8.2 and 2.8.3 and that’s why I didn’t issue an update. You can very well use the Plugin in 2.8.3 without any issues.

  • Sarah says:

    It is still not working. I even updated/repaired my database, reinstalled WP, and reinstalled the plugin. Any suggestions?

  • John says:

    I have updated several blogs to 2.8.3, from 2.8.2 and even 2.5.1 using both Installatron and Automatic Update plugin before installing and activating Bulk Delete, not had any problems so far. Not sure what that says to Sarah but it isn’t a problem for my instals

  • Jeremy says:

    I have same problem as Sarah. WP 2.8.3 PHP 5.2.6-5

    You can see screenshot here: http://www.ihuntsvillehomes.com/bulk

    • Sudar says:

      @Jeremy and @Sarah,

      Thanks for posting the screenshot. There certainly seems to be something wrong.

      Will it be possible for you to check the error log, to find out if there are any errors that have been logged by PHP or Apache?

      I am not able to simulate it at my end, but if I could simulate it, then I can surely fix it.

  • Sarah says:

    I don’t know what I’m doing with PHP or Apache to check for errors….Instructions? (You can email if you want.)

  • Tom says:

    Your plugin did not work for me. I am running 2.8.4 and have a news site that has about 10,000 plus posts in multiple categories. I try to delete posts in a sub category and it does not work. Goes to a blank page, I notice that the mysql queries have stopped on the server, and then nothing. I go back to the posts page to find that nothing has changed.

    Tom

  • Separatista says:

    Hi, is it possible to delete tags with this plugin? Also when deleting posts where are relations to custom taxonomies, these relations are not deleted. Thank you for your help…

    • Sudar says:

      @Separatista,

      Right now it is possible to delete only posts and not tags. When a post is deleted, it will delete only the comments and attachments associated with the post. If it was associated with any tags or categories, it will remove the association with those tags or categories but will not delete them.

      Hope this clears. Let me know if you still have any questions.

      • Separatista says:

        Yes, I understand, but when I use also custom taxonomies (some kinds of tags from WP 2.8, http://justintadlock.com/archives/2009/05/06/custom-taxonomies-in-wordpress-28) in posts, then association between particular post and custom taxonomy is not deleted. But it would be very helpfull if this association would be also deleted with deletion of posts…

        • Sudar says:

          @Separatista,

          Good point. I never thought of custom taxonomies, since I haven’t used them much. I will try to add this feature to the Plugin. Thanks for pointing it out.

          • Separatista says:

            Great, it would be very helpfull. And one more question, custom fields related to particular post are also deleted with this posts, right?

            • Sudar says:

              @Separatista,

              I am calling the wp_delete_post() function, which is the default one used by WordPress. So I guess it should also delete the custom fields. But I haven’t tested it, so I am not 100% sure. Thanks for bringing this to my attention. I will have a look at it and if it is not deleting it, then I will add the code to delete it also.

  • Jeff says:

    Thanks for the plugin.

    Now if you could only add in the options to Delete Categories and Delete Tags as well, that would be marvellous!

  • alexa says:

    hello sudarmuthu, why I get this error after activate it and go to the setting.

    WARNING: Posts deleted once cannot be retrieved back. Use with caution.

    Fatal error: Call to undefined function screen_icon() in /home/me/public_html/domain.com/wp-content/plugins/bulk-delete.php on line 143

    =================

    fixed, I go to line 143 and delete this –>

    and it work …

    thank you this is great plugin, it save me alot of times, really appreciate it :)

    alexa.

  • Rob says:

    This is an awesome plugin — saves me countless time.

  • Eric Wiegand says:

    Deleting the revisions will not delete the actual post, will it?

  • G.M says:

    Very useful

  • tdgphenix says:

    Is this compatible with 2.8.4? I installed the plugin but nothing shows up when I try to use it.

  • KJH says:

    Hi Sudar – any plans to update to work with WP 2.8.5? I just tried it and the Settings page only loads partially.
    Thanks!

    _KJH

  • Mike says:

    Sudar,

    Does the delete process also delete taxonomy references in the database to the post being deleted? I use WP custom taxos for navigation on the site so records can be filtered by county, booking date, etc (other taxos) so when the post delete with the current plugin I use (custom built) the tags do not seem to delete so the count in the menu stays at say 350 when there are only 300 post in the DB. It would be great if your plugin also handled the deletion of tags referenced to a post.

    Please let me know if this is supported.

    Thanks

    Mike

  • Randy says:

    I’m using WordPress 2.8.5 and successfully used your plugin once, then it stopped working and just immediately goes to a blank page no matter what options I try. No apparent errors in PHP log. Any ideas? Thanks…

  • leslie says:

    I have 9,000 posts I would like to delete, I was able to delete categories under 600 just fine. I read thru all the replies here about increasing something that is timing out? how do I do that? I am not well verse in html. I am using the lates wordpress upgrade. Thank you

  • Suneel says:

    Thanks it helped me a lot.

    A nice plugin.

    I would ask you to direct the users to Wordpress.org download page rather than being able to download the plugin from here directly.

    You can ask the users to rate there itself.

    • Sudar says:

      @Suneal,

      I provide link to both the zip file (hosted in wordpress.org) and also to the Plugin page. The reason I post both the links is that, if the user wants to directly download the zip file, he can save one more pageload and click :)

  • Fer says:

    I´ve installed the plugin vo.6 in Wordpress 2.8.6, activated it but it seems not to be working at all.

    I only get a blank page.

    any idea?

  • Fer says:

    Me again, problem was that my database was oversized. Solved it starting from zero (delete DB, reinstalling…) it´s working fine now

    Thanks for the plugin.

  • Ira says:

    I’m running WP 2.9 and Bulk Delete is not working. I have something over 3000 drafts that i want to delete and the Bulk Delete screen shows only 10 drafts. When I click drafts and delete the system hangs up looking for the website. Any idea what’s wrong. I know 2.9 now has a trash function and things are not permanently deleted. Thanks

    Ira

  • Henk says:

    Hi,

    also timeouts for me. Deleting 6K posts always timouts. Did increase executin time in htaccess. Any updates on plugin expected?

    thanks

    Henk

  • jq says:

    how do i install this plugin?

  • John says:

    Hi Sudar

    I just installed the plugin on 2.9.1, had to do it manually as zipped upload failed, message ” couldn’t move uploaded file to w-content/2010/01 or similar ( sorry should have copied it) but that is probably just an architecture problem.

    Anyway, one activated I get a almost blank screen on the Setting page.

    Just this, no input boxes.

    Bulk Delete
    Select the posts which you want to delete

    Looks like 2.9.1 will need a tweak!

    Thanks for the great plug in

  • John says:

    Just tried to re-install and message

    The uploaded file could not be moved to /home/nitmixc/public_html/wordpress/wp-content/uploads/2010/01.

    repeated, same as last time.

    I will leave it until you see this comment

    Thanks

    • Sudar says:

      @John,

      This is strange. Are you able to get other Plugins to work?

      Also if possible provide me these details.

      1) Which version of PHP you are running.
      2) Approximate number of categories and posts.
      3) Was it working before you upgraded to WordPress 2.9.1?
      4) Also which version of Bulk Delete Plugin you are using (I assume you are using the latest one)

  • John says:

    Tried uploading another plug in via the zipped upload feature but got the same result so it looks like an error due to upgrading to 2.9.1 from 2.7.1

    I will try removing the plugin and ftp ing in

  • John says:

    ftp it in and activated it, same result, empty setting page.

    This looks like a bug in the wp upgrade.

    • Mai says:

      I have the same problem. I downloaded the plugin and FTP’d it to my account. When I tried to delete a certain “category” which has about 1, 200 ++ posts, it just loads to a blank page.

  • John says:

    php 5.2.1

    thanks

  • Brett says:

    Hi Sudar,

    This plugin is just what I’m looking for. I’m having same issues as above

    I’m using PHP Version 5.2.11, WP-2.8.5 and the theme Thesis-1.6.

    I have aprox 250 categories 2,000 posts that I would like to delete on a regular basis.

    I get the blank manage screen also. Anything under the “Select the post which you want to delete” is blank. I switched Themes back to WP default to see if the theme had anything to do with it but no dice.

    Any advice would be appreciated.

    Brett

  • Miki says:

    Hi Sudar,

    I’m testing this plugin on my website. There is a bug. When I try to delete a category with about 2000 articles with “Only restrict to posts which are older than 120 days”, the plugin starts the process and finishes in 2 seconds and returns on the main screen of plugin: no posts were deleted. If I uncheck the “Only restrict to posts which are…” the delete starts for about 3 minutes and all posts in this category are deleted. Why, with days limit, does the plugin start and finish (with message “All the selected posts have been sucessfully deleted.”) without deleting posts?

    thank you very much :)

  • Miki says:

    ops, my wp version is 2.7 php version 5.2.12 mysql version 5.0.82sp1-log

    Thanks :D

36 Trackbacks/Pingbacks so far

Leave a Comment

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">