How do you manage thousands of posts? How to bulk delete old posts?

bbonds756

Newbie
Joined
Apr 30, 2010
Messages
8
Reaction score
0
Looking for a way to delete my old autoblog posts. I have several thousand posts and would like the old ones (maybe posts that are 6 months old) to be completely removed/deleted from wordpress and the sql database. If someone visits a link for a deleted post, i would like them to be redirected back to the home page of my site. i assume a cron job of some kind would take care of this. can anyone help?
 
there is a wordpress plugin named 'Bulk Delete' that deletes the posts in bulk based on the categories, tags or custom taxonomies.

If you want to try the SQL route, the following four queries should delete the posts you want to delete, plus any comments attached to them: DELETE FROM wp_commentmeta
WHERE comment_id IN (
SELECT comment_ID FROM wp_comments
WHERE comment_post_ID IN (
SELECT ID FROM wp_posts
WHERE post_category = 9 AND post_date < '2010-01-01'));

DELETE FROM wp_comments
WHERE comment_post_ID IN (
SELECT ID FROM wp_posts
WHERE post_category = 9 AND post_date < '2010-01-01');

DELETE FROM wp_postmeta
WHERE post_id IN (
SELECT ID FROM wp_posts
WHERE post_category = 9 AND post_date < '2010-01-01');

DELETE FROM wp_posts
WHERE post_category = 9 AND post_date < '2010-01-01';
This will permanently delete the relevant posts and comments. There is no recovering the data you delete this way. BACK UP YOUR DATABASE BEFORE YOU DELETE ANYTHING.

Also use the plugin 'Redirecting error 404 to Homepage' so that all the error posts will be redirected to homepage.

You can also try 'advanced permalink' plugin which redirects all the broken old posts to the correct new posts.
 
yep, Bulk Delete. sometimes a little buggy for me but otherwise works great
 
You can use the bulk delete plugin to delete form selected categories. The plugin can also be used to delete all drafts, revisions and pages too.
 
So each one of these four sql queries will delete posts older than a certain date? Should i be running this through phpmyadmin?

there is a wordpress plugin named 'Bulk Delete' that deletes the posts in bulk based on the categories, tags or custom taxonomies.

If you want to try the SQL route, the following four queries should delete the posts you want to delete, plus any comments attached to them: DELETE FROM wp_commentmeta
WHERE comment_id IN (
SELECT comment_ID FROM wp_comments
WHERE comment_post_ID IN (
SELECT ID FROM wp_posts
WHERE post_category = 9 AND post_date < '2010-01-01'));

DELETE FROM wp_comments
WHERE comment_post_ID IN (
SELECT ID FROM wp_posts
WHERE post_category = 9 AND post_date < '2010-01-01');

DELETE FROM wp_postmeta
WHERE post_id IN (
SELECT ID FROM wp_posts
WHERE post_category = 9 AND post_date < '2010-01-01');

DELETE FROM wp_posts
WHERE post_category = 9 AND post_date < '2010-01-01';
This will permanently delete the relevant posts and comments. There is no recovering the data you delete this way. BACK UP YOUR DATABASE BEFORE YOU DELETE ANYTHING.

Also use the plugin 'Redirecting error 404 to Homepage' so that all the error posts will be redirected to homepage.

You can also try 'advanced permalink' plugin which redirects all the broken old posts to the correct new posts.
 
no!!!!!! big^G with wtfpwn your a$s ... keep the pages ... buy a bigger host if you have to but you do not want to delete them .... also more pages = more stuff for incoming searches ... so dont delete them ...
 
I used a plugin called blog pig or nuke pig or something like that. It worked really well to bulk delete and different things like that.
 
the problem is i think my database is corrupted at a certain date (previously i had ran a mysql query that didnt delete all posts correctly now im seeing problems like post comments that cant be deleted, or it showing i have 4 new comments when in fact its about 20) therefore i would like to run an sql query to delete all posts and associated data from a certain date.
 
there is a wordpress plugin named 'Bulk Delete' that deletes the posts in bulk based on the categories, tags or custom taxonomies.

If you want to try the SQL route, the following four queries should delete the posts you want to delete, plus any comments attached to them: DELETE FROM wp_commentmeta
WHERE comment_id IN (
SELECT comment_ID FROM wp_comments
WHERE comment_post_ID IN (
SELECT ID FROM wp_posts
WHERE post_category = 9 AND post_date < '2010-01-01'));

DELETE FROM wp_comments
WHERE comment_post_ID IN (
SELECT ID FROM wp_posts
WHERE post_category = 9 AND post_date < '2010-01-01');

DELETE FROM wp_postmeta
WHERE post_id IN (
SELECT ID FROM wp_posts
WHERE post_category = 9 AND post_date < '2010-01-01');

DELETE FROM wp_posts
WHERE post_category = 9 AND post_date < '2010-01-01';
This will permanently delete the relevant posts and comments. There is no recovering the data you delete this way. BACK UP YOUR DATABASE BEFORE YOU DELETE ANYTHING.

Also use the plugin 'Redirecting error 404 to Homepage' so that all the error posts will be redirected to homepage.

You can also try 'advanced permalink' plugin which redirects all the broken old posts to the correct new posts.


Can someone help me combine the above suggested SQL queries with the following query so i can delete all posts that are a certain number of days old instead of older than a certain date?

DELETE FROM `wp_posts`
WHERE `post_type` = ?post?
AND DATEDIFF(NOW(), `post_date`) > X
 
Why would you want to delete the old one ? Is there any harm letting it there ?
 
You are having any problem with the old post then why don't you leave as it is.
 
Looking for a way to delete my old autoblog posts. I have several thousand posts and would like the old ones (maybe posts that are 6 months old) to be completely removed/deleted from wordpress and the sql database. If someone visits a link for a deleted post, i would like them to be redirected back to the home page of my site. i assume a cron job of some kind would take care of this. can anyone help?

http://wordpress.org/extend/plugins/wp-mass-delete/ is what you're looking for.
 
Back
Top