WordPress Suicide

WordPress logoThis was a fun one to write. What if you wanted to start over again? Just wipe the slate clean and start blogging without any baggage. Well, that’s actually hard to do unless you’re comfortable using the MySQL command line client (or phpMyAdmin).

So I whipped up a little plugin that does just that, and no more. Install it, activate it, and you’re just a single click away from blogging salvation (or is it purgatory?). In other words, this plugin gives you the power to delete all your blog posts from the database in one fell swoop. You can also use it to delete categories, comments, links, and custom fields, as well as users and blog settings. Here’s a screenshot:

Screenshot of WordPress Suicide plugin

Instructions

  1. Download Suicide v2.0 from the WordPress.org Plugin Directory (or from me here)
  2. Unzip the file and upload the suicide folder to your wp-content/plugins/ directory
  3. Activate the plugin
  4. Go to Tools > Suicide (and contemplate your blogging fate)

Note: by default, this plugin will delete all content associated with your blog except users and settings. That way you’re left with a functional, though effectively empty blog. Consider backing up your blog before “committing Suicide”. I assume no liability for data loss suffered through the use of this plugin. Use at your own risk!

In all seriousness, you might want to use this plugin if you recently imported your posts into WordPress from another blogging platform but something went horribly wrong (or you were considering importing your Haloscan comments) and you want to start the import process over.

Update: If you want more nuanced control over what particular records get deleted, say based on date or some other criteria, check out my SQL Executioner plugin. It allows you to send any SQL query/command to your WordPress database. If you don’t know SQL, no worries, just leave a comment with what you want, and I (or someone else) will respond with a query you can try.

Questions, comments, and suggestions are always welcome. If you’re interested in contributing to the code behind Suicide, it’s hosted on GitHub.

Feel free to if you found this useful.

119 Comments

I assume this only works if you’ve maintained the default MySQL prefixes in the DB setup.

Correct?

Nope, I made sure to reference the table names using the $wpdb object, so if you install the plugin, the interface (and the corresponding TRUNCATE TABLE queries) will reference the correct table names for your install.

Brilliant! Spiritual! True control over your online life.

That plugin is hot! That plugin is terrible! That plugin scares the shit out of me! Keep that plugin away from me!

I know, I had such unparalleled joy in writing it.

The funny thing is, it actually solves an important problem, especially for people moving to WordPress from another platform, but without command line mysql experience and/or access in order to drop tables in case things go awry.

And as Brian adds, it offers almost a spiritual solution to Shelley Powers’ recent musing:

I’m not sure that most personal weblogs should remain for longer than a few years.

Though I imagine Shelley would be more in favor of a permanent archive, as opposed to:

rm -rf blog/
DROP DATABASE wordpress

Yikes–what were you thinking?

Man what a great plug-in. I’m in the process of moving over to wordpress and have been playing with all sorts of stuff and filling up the DB with crap. I must have re-installed WP 10 times by now, but with this nifty little app, I can just blow away the DB and all is once again well in the world.

Thanks a million.

Thanks, I needed to get rid of what problems that pesky nucleus->WP import script had caused me

[…] Curioso plugin de WordPress ideal para suicidar tu blog en un solo clic. Borra todos tus posts, categorías, en fin, todo. Concuerdo con el autor, tuvo que ser bastante divertido hacerse un plugin que rara vez creo que alguien lo use, por lo importante que es pasarse 5 años escribiendo. […]

[…] – WordPress Suicide: el nombre lo deja claro, Suicidio para WordPress, deja tu blog como recién nacido, se pule las tablas de la base de datos y te deja el blog en blanco, pero con la base de datos corriendo. Sinceramente a mi no me parece muy útil. Lo que me ha hecho gracia es esto al final de la web del autor. […]

Wow what a compliment to be on someone’s Stupidest WordPress Plugins List!

I’m the one who made that list. With stupid I didn’t mean to insult you nor your plugin. It’s just that I was looking for odd plugins and I found yours. And I’ve got to say that your plugin is the most useful of all I found.

Malkav, no worries, I was actually honored to be on your list, but I appreciate the clarification.

this is great! i am having a really hard time importing from blogger in beta and this suicide plugin makes it much easier to go back to square one when things don’t work out.

[…] Finaler geht nicht: WordPress Suicide. Alles weg, auf einen Knopfdruck. Falls das Bloggerleben nach dem rosaroten Einmarsch nicht mehr lebenswert scheint. (Manchmal kann sich ja auch auf den Hoster verlassen, dann braucht es kein Plugin …) […]

[…] Sollte die Auktion scheitern, kommt es zu einem WordPress Suicide (Rate Now!)  Loading … […]

[…] Mit einem Linktipp zu einem kostenlosen Iconset Notizbuch möchte ich einfach mal auf pixelgraphics.de hinweisen. Ganz feine Sache das Blog, auch für grafische Nixblicker wie meine Wenigkeit. English Russia ist auch immer einen Klick wert, hier eine Fotoserie zu Tschernobyl, bedrückend, erdrückend und doch – sehr interessant. Solltet Ihr mal Euer WordPress-Blog löschen wollen, hier das finale Plugin. WordPress Suicide. […]

At any rate, I can heartily recommend Justin’s WordPress Suicide.

[…] WordPress Suicide (just in case we screw something up) […]

[…] Creo que no hace falta decir el cuidado que hay que tener al hacer estas operaciones y lo necesario que es disponer de copia de seguridad por si algo sale mal o nos tocará volver a empezar. Si hay que volver a empezar existe un plugin llamado WP-Suicide (descarga directa) que deja el blog sin posts, comentarios ni categorías para volver a empezar desde cero sin tener que tocar la instalación de WordPress. […]

[…] WordPress Suicide. So I can blow away the data on the test version and upload templates etc. from the copy I’ve been working on here. […]

[…] ダウンロード:WordPress Suicide – Justinsomnia […]

[…] Suicide adalah sebuah plugin untuk wordpress jika suatu saat ingin menghapus blog dengan cepat dan mudah. Tentunya dengan pertimbangan yang tidak begitu matang, saya memutuskan untuk memulai kembali dari awal menulis di blog ini. Menulis itu memang susah yah… […]

[…] Suicide is plugin for wordpress if you want to quickly delete your blog. And this time is for real! I’ve already killed myself twice. But, don’t worry, actually I just moved to a new place. […]

[…] An interesting WordPress Plugin – WordPress Suicide It’s returns your WordPress install back to it’s original state except for the user tables. That means if you have a bad import, you can remove the posts and comments and try again. […]

[…] During testing, for your convenience do consider WordPress Suicide. You can use it now, compared to before as reported by David in this post. Don’t delete all tables, use these settings: […]

al

i get this error:

WordPress database error: [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 1]
TRUNCATE TABLE

deleted.

al, thanks for the heads up. I’ve been lazy testing my plugins for WordPress 2.1, and of course the “linkcategories” table was renamed “link2cat” in v2.1. So I’ve updated my plugin (v1.1) to accommodate this change.

al

justin it works fine for me now. just update the version number for the admin panel from 1.0 to 1.1
Me mola este plug y al que le parezca estúpido debería usarlo en su blog.

Thanks for this great plugin. Saved me a lot of manual deleting. :)

[…] 1. While you’re testing the blogger import feature you can try out WordPress Suicide plugin; this plugin will help you clear all the posts in WordPress. […]

[…] WordPress Suicide é um plugin para o wordpress que faz exactamente isso.  […]

Nolan

Hi Justin. Thanks for the plugin; it is helping me very much while testing my own plugin ;)

Anyway, a simple bug I noticed, if you delete post2cat, it doesn’t update category.category_count, so the manage categories page will erroneously report the old numbers of posts in categories.

Erm, not sure if that was very clear. Anyway, thanks!

Nolan, ha, you’re right. That’s a use case I hadn’t quite anticipated. Another scenario would be deleting only wp_comments, but since wp_posts caches the comment count, the old comment counts would still remain.

Though it’s somewhat outside the scope of the plugin, I can see how flushing those counts would be useful. I’ll look into adding support for that.

You’re plugin has worked great for me while testing my migration from blogger to wordpress.

I’m getting a small error though. After I Suicide with the default settings I get an error on my WordPress page in my Recent Entries sidebar. Heres the error.

Warning: Invalid argument supplied for foreach() in /home/.blah/user/site/wp-includes/category-template.php on line 10

Any ideas?

After some testing I found that this error only takes place if I delete wp_categories.

Once I get the error I can’t get rid of it. I’ve been using phpmyadmin to restore my test database each time and that clears the problem up.

Here’s what I’ve been able to do to get around this. I suicide the defaults except wp_categories. Then I use phpmyadmin to manually set the category_count field of all the remaining categories to 0.

Everything works fine now.

Nick, the reason for the error is that after you delete all your categories, WP expects there to be at least one (the default), so some functions break because it’s not there. The easiest fix is to go back and add a default category after deleting your wp_categories table. I have not yet add the ability to clear the cached category or comment counts.

[…] WordPress – pick a template (Andreas Viklund’s WP-Andreas01), install and activate plug-ins (WP Suicide, New Blogger […]

[…] They are New Blogger Import plugin that I used to import all the post from Blogger platform and the WordPress Suicide plugin that I used to clear up the post during the testing phase. You can read more about the use […]

[…] a WordPress plugin to import blog posts and comments from a New Blogger account. Oh, install WordPress Suicide as well. It is useful when the import failed, but use it with […]

Hi Justin, thanks for the plugin. It worked great! All my posts and categories were deleted, even my blogroll! The blogroll was a mistake though. But, it’s okay. =)

micky

will this plugin remove my theme modifications too?

micky, nope, this plugin only affects the database, it does not touch the filesystem, where your theme files are be stored—and can be easily recovered by downloading WordPress again and replacing the wp-content/themes/default folder.

Thanks- WP-Suicide worked great or me- I had imported a bunch of RSS stuff for testing and once I was finished I needed to get rid of it all. WP-Suicide took care of things quick-n-easy.

Left you a comment over at WordPress Support

Thx!
RH

R. Richard, thanks for the props, glad your Suicide worked out. ;)

[…] install WordPress Suicide as well. It is useful when the import failed, but use it with caution! . WordPress suicide comes […]

[…] plug and play. There are a lot of issues using this plugin. The author himself provides a link to WordPress suicide to mass delete your wordpress posts in case the import fails and you have to try again. However, […]

Eoin Campbell

The link on your home page to download the 1.0 version is incorrect. It points to the 1.1 Zip file.

“Note: for WordPress version 2.0.x, download wp-suicide-1.0.zip”

Eoin, sure enough. Thanks for the catch. Fixed.

Sweet, just what I was looking for. I’m moving my blog to WordPress and I’m writing my own export/import, this is great for cleaning up after testing. Thanks!!

Wow, this is perfect for people with OCD like me. ;-)

Thanks — this was a life saver. Blogging since 2003 with over 1,580 posts on Blogger and imported into WordPress but permalinks were incompatible. I used WordPress Suicide… blew them all away and re-imported… PIECE OF CAKE… I will give your site a plug !!!

Thanks…

Eric TF Bat

Excellent – thanks. Exactly what I needed; no fuss, no muss. Well done.

hbiyani

this tools is a life saver. thanks for the script.

[…] WPSuicide : You will commit suicide a number of times, believe me! – This plugin deletes all your posts/comments etc from the wordpress blog. […]

Is there any way to delete posts from just a given category?

Just updated this plugin for the new tables in WordPress v2.3. Enjoy!

Ron, not with this plugin, but there should be a user-friendly way. I didn’t find anything after a quick Google search. Maybe it’d be worth building.

[…] I had to delete the data and start again a few times which wasn’t too hard thanks to a handy plug-in which deletes the required data.  Once I’m happy that everything is running as it should […]

telecommatt

testing new wordpress install and moving from wordpress.com to my own host. this has been a huge timesaver. cheers!

Steven

Would be great when the plugin would auto-disable itself after running a suicide action – will improve the safety net for accidentally running the plugin

Steven, great idea, I just added that safety feature in v1.3. Enjoy.

Great! Just what I was looking for!
Thanks, keep up the good work, mate.
Diego

Kelly H

This is awesome! Saved me a bunch of time – thank you !!!

man, this really is a life saver. just saves a lot of time from having to resetup everything I spent time setting up.

thanks!

I know, I use it all the time, especially when helping anyone with a transition from another blogging software. Glad to hear it worked for you.

Paul

I had an old WordPress blog which I neglected and when I saw it this week – Oh My God – I had forgotten to switch off the Comment posting and there were 2500 Spam comments.

I started deleting them and then decided to search for a plugin on Google – Bam – Your site came up and I used the plugin which saved me a ton of time. Worked beautifully.

Many thanks for that brilliant plugin.

where do i download the wordpress suicide plugin? I can’t find it.

Caroline, click the “wp-suicide-1.3.zip” link in the instructions section, underneath the screenshot.

SHGIrl

nothing happened when I did it. I tried twice. I activated..pushed the button..got for the love of god and said yes..and my imported journal is still there :(

Umm, strange. What web browser were you using? What version of WordPress?

ahhh thank you so much! You just saved me a TON of time. For the love of god, I am SO sure.

Jayson

awesome, I had to delete about 12k spam comments on a friend’s blog. it was better to just delete all of them than do it selectively. thanks for this.

Kayte and Jayson, you’re very welcome. Glad this came in handy…

justin i uploaded suicide 1.3 and i pressed yes button but even one post was not deleted iam using IE browser and wordpress 2.3.2 verson please find a solution for me i need to delete all the posts in my blog

pawan, the only thing I can suggest is to try Firefox. It’s possible that for some reason the database user account for your blog does not have truncate table permissions. I would check with your webhost.

Thanks for this – I am sure the number of comments I need to delete is over 10,000. But the old blog in question is WP version 1.5.1.3. Do you know if wp-suicide-1.0 will work for this? Should I take a chance?

Thanks!

Dave the first version that WordPress Suicide supported is WP 2.0. There’s a very good chance it will work with WP 1.5.x at least for the comments table.

I might recommend upgrading first (since that’s important anyway) and then running the latest version of WP Suicide.

Wow! Quick response!

Thanks for the help. The old blog is useless now as it is so I will go ahead and try it and let you know. An upgrade may be in order as well.

Yes, it worked perfectly. I’m a happy man. Good work.

Dave, glad to hear it. Happy blogging.

Dn

Justin,

Seems like a great plugin, thanks for taking the time to write it.

Do you know of any plugin for those that only want to commit “partial suicide”? :-) Like say, removing all posts older than a year?

No, but for a small donation I could write you one… :)

It’s a really great idea though. Donation or not this may be something worth working on. Sort of a WP-specific PHPMyAdmin in a plugin.

Dn, I just wrote a plugin (and a blog post) regarding your request. Check it out at The WordPress SQL Executioner.

Thanks for this one. I recently had some problems with my blog and decided to take it as an opprotunity for a relaunch. I was wondering how I would get rid of everything I had before.

Great plugin. The “Yes” button doesn’t work in IE. Change the “button” HTML tag to an “input” tag to get the value to be posted in the form.

mark

Will it worked for unpublished posts as well?

mark yes, it deletes *everything*

Thanks fella. Saved me a ton of time.

Works great on 2.5. Just sent you $5.

Gizzorge

Thanks, man. It worked like a charm. Saved me about an hour of delete, confirm, wait, repeat.

Wicked plugin :) I’ve just deleted 12,453 spam comments, and the checkbox – “For he love of God, are you sure?”, literally killed me. :D thanks dude!

caustin

Fantastic. Thanks for your work.

One thing that I have been looking for is a plugin that would allow for a “scheduled suicide”, so that an implementation of wordpress could be used in a demonstration capacity.

For example, if I wanted all posts/comments/etc. to be deleted every hour, I could set up a schedule for that to happen.

Thoughts?

Thanks again.

caustin, sounds like it’d be easier to set up a cron…

ddeconin

Hi, I tried this plugin on my test blog ( wp 2.7.1 ) and it doenst seem to have any effect… is it still supported ?

thanks for the plugin mate!

Great plugin thanks for this, will write a link up to it on my blog and twitter this weekend

Rog

Used this plugin to delete all posts and categories, the only ones left unchecked where.
# wp_users
# wp_usermeta
# wp_options

Then I create a new categery that got the id 1 but on the front end it says no categories even when I have posted in it and the posts show up fine. Is it something woth the link to cat that is f***d up or?

I use WP 2.2.3

Rog

forget about the previous comment. It was and erorr in my newly installed template that caused the no categories problem.

Rog, glad to hear you go everything figured out. But
please upgrade your WordPress to v2.8.4. There have been numerous security holes discovered and patched since v2.2.3!

rpd

Installed your plugin but when try to use it get – you do not have sufficient permissions to use this page(!!!! aaargh!!!!!)

rpd, what’s your user level in WordPress? I’m assuming you’re referring to a WP security issue and not the fact that your WordPress database user doesn’t have permission to truncate tables?

Whoa! This is awesome!
Thank you.

Derek

I’m new to WordPress, but have the same issue as rpd (i.e. “You do not have sufficient permissions to access this page.”). What do I do?

Derek (et al), I just updated WordPress Suicide for WordPress v2.9 and above. I also made a slight change to the permission scheme for the plugin which might explain the issue you were having. Note, in order to run this plugin, your user role must be “Administrator”. Let me know if you’re still having issues. Thanks.

Shit hot plugin. I was trying to get another plugin to work on WPMU but it wouldn’t work, yours works a treat. cheers

bruce

just used this and it worked great. I had just set my blog up and was screwing around with it and decided to start over. googled how to clear data from wp and found this site. cool

thanks a lot, my local wp install was bloated with data, this plugin helped in clearing it up!

Thank you for this awesome plugin… I couldn’t access my site and renamed the plugin directory, created a new plugin dir then installed this and ran it to delete over 2000+ posts that an autoblog plugin had harvested over night! So, when I woke up this morning, my site was totally blank, when I tried to go to the admin section, it went straight to install.php every time. Thank you for this and saving me hours upon hours of work reinstalling everything!! Whew.

Although I do caution those people that aren’t that experienced with WordPress with this plugin. Suicide is a great name for this as it could mess up your entire world! So, always use caution and know what your doing when using this plugin.

Thanks again!

Herbal Botany

Yuri

i have a blog with several quality PAGES, and about 100,000 low value POSTS (generated by auto-blogging software). I now want to rebuild this into a quality site Can your plugin delete all my posts but leave everything else?

Yuri, the wp_posts table contains all posts, pages, revisions, and media attachments, so if you use WordPress Suicide to delete it, you’ll lose everything. Instead, I’d recommend you check out my other plugin, The WordPress SQL Executioner, where you can execute a query to just delete posts but not pages.

Couldn’t manage to get the setting for that plugin. I badly need to reset my WP blog. I tried before but failed miserably. I will try more. and report.

OOH la la. Man you are great. Why is not anyone responding to this very need of resetting wp to default? Especially if anyone uses autoblog software things mess after a while and you need to reset it. Anyway you did it. As I mentioned earlier I tried to do this and installed mass post delete plugins but that just didn’t work. Now I will donate though small. Keep up the good work.
By the way I found the settings hyperlink in the tools section after reading in the plugin description. Thanks.

Thanks a ton! This is perfect for theme development. I often have pages or posts specific to a theme, so this is just what I was looking for.

Why is this plugin not in the repository?

Ben, short answer: laziness (and it’s likely that it predates the repo). But thanks to your contribution, you gave me a reason to submit it.

Andrew Orham

THAT WAS AMAZING!!!
Had a site with thousands of test posts. Needed to clean it up. Your plugin did the job and SUPER FAST. Thank you!

Care to Comment?

Or if you'd prefer to get in touch privately, please send me an email.

Name

Email (optional)

Blog (optional)