WordPress Suicide

The latest version is 1.3, released November 3, 2007

This 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 client on the command line (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. For Wordpress v2.3 and up, download wp-suicide-1.3.zip (v1.3)
    For WordPress v2.1.x–2.2.x, download wp-suicide-1.1.zip
    For WordPress v2.0.x, download wp-suicide-1.0.zip
  2. Unzip the file and upload wp-suicide.php to your plugins directory:
    /path/to/wordpress/wp-content/plugins
  3. Activate the plugin (don’t forget!)
  4. Goto Manage > 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 using WordPress 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 wrong (or you were considering importing your Haloscan comments) and you want to start the import process over.

Update: If you want more nuanced crontrol over what particular records get deleted, say based on date or some other attribute, 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.

relatedposts

92 comments

name
blog (optional)
comment

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) [...]

cool plugin!

[...] 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: [...]

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.

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

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

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, [...]

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…

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

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

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

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

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.

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.

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.

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.

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.

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.

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