WordPress tips: Use SQL to manage your comments

Source: Internet
Author: User
Keywords WordPress

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Of course, if you just want to delete a few comments or some other simple work, wordpress an efficient built-in comment management interface is enough, we can easily manage some comments in the WordPress Control Panel. In the case of bulk deletion of comments or other work related to comments, we can use a few simple SQL, can be faster and more convenient to solve. In today's WordPress tutorial, I'll show you some super useful SQL queries to make it easier to manage your WordPress comments.

Before that, you need to be aware

Don't forget to make a backup of your database before testing any of the queries below.

Don't forget to change the default table prefix WP_ when using the following SQL statement.

Delete all spam comments

When you have more than 100,000 in the WordPress spam comment queue, deleting them using the built-in delete all spam Comment button may result in a PHP memory error. To avoid this, just use this simple SQL request to delete all spam comments at once.

DELETE from wp_comments WHERE comment_approved = ' spam '

Delete all comments between two dates

Is there a "spam comment attack" in a limited time? Here is an easy way to delete all comments between two dates.

DELETE from Wp_comments

WHERE comment_date > ' 2013-11-15 01:10:04 '

and Comment_date <= ' 2013-11-20 00:10:04 '

Delete all comments Awaiting review

If your "pending comments" queue is filled with 99% of spam comments, and you don't want to manually review them, this SQL command will help you immediately clear all comments awaiting review.

DELETE from wp_comments WHERE comment_approved = ' 0 '

Disable comments for all articles immediately

Do you want to disable all of your article comments? If you are using WordPress with your own comments management, you will be exhausted! Why not use this super simple SQL query?

UPDATE wp_posts SET comment_status = ' closed ', ping_status = ' closed ' WHERE comment_status = ' open '

Deactivate older article comments

In order to limit spam comments, why not close older article comments? The following SQL statement automatically closes comments earlier than 3721.html ">2014 year January 1":

UPDATE wp_posts SET comment_status = ' closed ' WHERE post_date < ' 2014-01-01 ' and post_status = ' publish '

Of course, you can change the corresponding time according to your own needs.

Delete a comment that specifies the reviewer URL

What if you want to delete all the messages from the reader? Here is a very simple way to bulk delete all comments in a particular URL with a simple SQL query. If you just want to delete the relevant content of these URLs, you can use it:

DELETE from wp_comments WHERE comment_author_url like "%www.wpmee.com%";

Search and replace comment content

If you want to replace all comments specific words or sentences, use a very convenient SQL query function of MySQL to solve the problem.

UPDATE wp_comments SET ' comment_content ' = REPLACE (' comment_content ', ' originaltext ', ' Replacedtext ')

Enable only registered users on a global scale to comment

Only registered users can participate in the comments of the article, such a method to avoid the vast majority of spam comments.

UPDATE wp_posts SET comment_status = ' registered_only '

Respect the achievements of others, reproduced please specify: http://www.wpmee.com/manage-wordpress-comments-using-sql/

All right, here's the tutorial. Most of these are simple SQL query statements, the last reminder, the operation of the database must be careful, before the operation please back up.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.