1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MySQL Query Needed to Delete Older Comments in Wordpress

Discussion in 'Database Discussions' started by Another Blogger, Feb 28, 2013.

  1. Another Blogger

    Another Blogger New Member

    Joined:
    Jan 4, 2013
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    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.
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    12,119
    Likes Received:
    31
    Trophy Points:
    48
    Location:
    Pennsylvania
    You might do better to ask about this sort of thing over on wordpress.org
     
  3. Another Blogger

    Another Blogger New Member

    Joined:
    Jan 4, 2013
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    ^^ Thanks for your reply. I asked there already but didnt get a single reply in 4 days. :(
     
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    12,119
    Likes Received:
    31
    Trophy Points:
    48
    Location:
    Pennsylvania
    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! ;)
     
  5. Another Blogger

    Another Blogger New Member

    Joined:
    Jan 4, 2013
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    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.
     
  6. cPanelJared

    cPanelJared cPanel Staff
    Staff Member

    Joined:
    Feb 25, 2010
    Messages:
    1,835
    Likes Received:
    12
    Trophy Points:
    38
    Location:
    Houston, TX
    Instead of closing the thread, would you mind sharing the solution you found for the benefit of the community?
     
  7. Another Blogger

    Another Blogger New Member

    Joined:
    Jan 4, 2013
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    ^^ 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.
     

Share This Page