Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have WP website with over 40,000 posts. Now I'll like to delete all posts, categories and tags. So All content and related meta. All I want to keep is static files. Is there a easy way to do this through database? Some query to drop all relevant tables? Sorry, I am not good with db and code, so please give me detailed explanation or full query. Thanks a lot. Plugins or any other solution, don't work for me, I need mysql query.

share|improve this question
    
Can you explain what you mean by "static files"? I take that to mean "hard-coded php, html, css, and javascript files" but I have learned not to assume :) –  s_ha_dum May 4 '13 at 1:24
    
Just take the back up of all the wordpress and database now installl new wordpress on your server after that replace the theme and plugin folder to your new wordpress and activate the theme you will get all same site without your previous data if want to add any data rplace the perticular table from your backup database to new database hope this will help you –  Vikas Gautam Sep 18 '13 at 4:29
add comment

2 Answers

You wrote that you are not good with database, so please be extremely careful with the advice I present here.

First, learn how to backup your wordpress database and restore it from the backup file. This is critical to save you from catastrophe.

Second, there may be a plugin that will help you. I haven't looked but a friend was and said he found a "data migration" tool for wordpress.

Next, you can delete data from selected tables. Do not "drop" tables as that will eliminate the data structure in addition to the data. The result will be a broken wordpress. However, there are dependencies you must understand before using the SQL delete command.

A better approach would be learn to use a "selective" restore, loading only the tables that have the data you want to keep, e.g. wp-users. The idea here is to use the backup files to create a "baseline" database setup that suits your purpose.

If you find a data migration tool, you follow this procedure:

  1. backup the current database

  2. create a new database (and wordpress site) and use the migration tool to move data into it. Use the "new" wordpress site to test everything.

  3. If you are successful, then adjust the DNS records to point to the new site. You could adjust the wp config of the original site to point to the database.

Keep in mind the data integrity. It is extremely important.

I hope something in this helps you.

share|improve this answer
    
Hi Mophilly, Thanks a lot for detailed answer. I understand importance of backup and do use backup, but thanks for advice. There is a plugin Bulk Delete, but this works only for up to around 1,000 posts (and bit slow) so not solution for me. So in general what you advise me is to recreate website, just without all content that I want to be removed. Test that and if it's fine switch website to this new db. I hope I understand that right - because that is what I just started doing ;) –  Larson Apr 5 '13 at 7:57
    
I was hoping to get some mysql statement (or 3) that will say deleted all posts and meta, all categories and all tags. But as looks like something like this does NOT exist, i will start with thsi process. 1) New WP and clean database 2) move users, etc to new db plus all files from old site 3) test new site, if working switch to that one. I want mark this as resolved yet, as I hope that is some faster solution - some sql statement or similar, as process as above will work, but it is bit slow. –  Larson Apr 5 '13 at 7:57
    
Mophilly, just to say once more that I am very thankful to your detailed answer. Really nice from you. –  Larson Apr 5 '13 at 7:58
add comment

While not instant, if you just need it once it might be more robust just do it through interface.

You can use screen options (top right corner of admin) to increase amount of items per page (I think it handles up to 999, but you might need to set less for it to work properly) and delete them via bulk actions page by page.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.