MySQL Query Needed to Delete Older Comments in Wordpress

Jan 4, 2013
20
0
1
cPanel Access Level
Website Owner
Hello everyone

I run a self-hosted WordPress blog which has approx. 2000 topics. Many of them contain more than 200 comments.

I want to have a MySQL query which first searches for posts which have more than a fixed number of comments such as 50 comments and then delete the extra old comments.

For example, the query searches for posts having more than 50 comments and then it deletes all old comments from those posts to make their comment count under 50.

I'll really appreciate if someone can provide such query statement.

Thanks in advance.
 

Infopro

Well-Known Member
May 20, 2003
17,113
507
613
Pennsylvania
cPanel Access Level
Root Administrator
Twitter
Probably has been answered so many times no one cared to help you out.

/http://wordpress.stackexchange.com/questions/15870/how-to-delete-old-comments-by-date
/http://gerardmcgarry.com/blog/wordpress-deleting-comments-old-blog-entries


I googled: delete old comments on wordpress


GL! ;)
 
Jan 4, 2013
20
0
1
cPanel Access Level
Website Owner
Sorry to say but I have already checked those topics. They came on first page while searching on Google. My question is different. I dont want to delete all older comments. I want to delete comments from only those topics which contains more than 50 comments. I want to keep latest 50 comments from each topic and delete all previous comments from those topics.
 
Jan 4, 2013
20
0
1
cPanel Access Level
Website Owner
^^ No one helped so I decided to manually delete comments from older topics using Wordpress Admin CP. It'll take time but thats the last option to do.