最近出现历史评论中的网址出现危险异常的情况,这对于 WordPress 网站来说是一个噩梦,所以想要删除这些异常的评论链接。但是,如果评论太多,一个个去排查工作量太大,所以考虑删除评论中的网址字段,或者删除评论人链接。
您是否要在WordPress中删除许多待处理的注释? 如果您收到大量垃圾邮件评论,这很容易发生。
Normally, deleting comments in WordPress is easy, but it gets trickier when there is a large number of pending comments. You may even come across weird errors while bulk deleting comments if there are too many of them.
通常,在WordPress中删除评论很容易,但是当有大量待处理的评论时,它会变得更加棘手。 如果注释太多,则在批量删除注释时甚至可能会遇到怪异的错误。
In this article, we’ll show you how to easily bulk delete all pending comments in WordPress, step by step.
在本文中,我们将逐步向您展示如何轻松地批量删除WordPress中所有待处理的注释。
使用代码删除评论中的网址、邮箱、评论人链接
在 WordPress 网站提交评论时,需要选填“网址”这个表单,对于用户来说会觉得很麻烦,同时对于博主来说也会造成不安全的后遗症。其实完全可以移除网址表单,如果之前已经有一些评论包含了评论人网址,还可以直接移除。在主题的 functions.php 添加以下功能代码即可:
- //移除网址表单
- function url_filtered($fields)
- {
- if(isset($fields[‘url’]))
- unset($fields[‘url’]);
- return $fields;
- }
- add_filter(‘comment_form_default_fields’, ‘url_filtered’);
- // 移除邮箱地址
- add_filter(‘comment_form_defaults’,’remove_email’);
- function remove_email($comment_form_HTML_arr){
- //删除email文本框
- unset($comment_form_html_arr[‘fields’][’email’]);
- //修改评论提醒内容,去掉电子邮件相关的提醒。
- $comment_form_html_arr[‘comment_notes_before’] = ‘<p class=”comment-notes”>’.sprintf( ‘ ‘ . __( ‘Required fields are marked %s’ ), ‘<span class=”required”>*</span>’ ).'</p>’;
- return $comment_form_html_arr;
- //移除评论人名字的链接
- function disable_comment_author_links( $author_link ){
- return strip_tags( $author_link );
- }
- add_filter( ‘get_comment_author_link’, ‘disable_comment_author_links’ );
取消电子邮件时必填项
首先,在 wp 后台>>settings>>讨论>>讨论设置>>其他评论设置中,取消勾选“评论作者必须填入姓名和电子邮件地址”,如下图:
注:此方法只对使用 WordPress 默认评论表单的主题才有效,如果主题自定义过评论功能,是没办法生效的,只能靠自己修改主题的自定义评论文件。比如打开主题的 comments.php 文件,搜索 $comment_author_url 一般就可以定位到网址表单的代码。
使用插件删除评论中的网址、评论人链接
插件名称:Comment Link Remove
插件地址:https://wordpress.org/plugins/comment-link-remove/
如果您有数百条待处理的注释,那么我们建议您使用插件方法将其删除。
2.使用插件在WordPress中删除大量待处理的注释 (2. Deleting Large Number of Pending Comments in WordPress Using a Plugin)
The quickest way to delete a very large number of pending comments is to use a plugin.
删除大量待处理注释的最快方法是使用插件。
This will delete your pending (and spam) comments permanently. We recommend making a backup of your WordPress site before proceeding, just in case you change your mind later.
这将永久删除您的待处理(和垃圾邮件)评论。 我们建议您在继续操作之前备份WordPress网站 ,以防万一您以后改变主意。
First, you need to install and activate the Delete Pending Comments plugin. For more details, see our step by step guide on how to install a WordPress plugin.
首先,您需要安装并激活Delete Pending Comments插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。
Upon activation, go to the Comments » Delete Pending Comments page in your WordPress admin. You will see a message letting you know how many pending comments there are.
激活后,转到WordPress管理员中的“ 注释”»“删除待处理注释”页面。 您将看到一条消息,让您知道有多少未决评论。
Note: This figure includes spam comments, which are deleted at the same time as the pending comments.
注意:此图包括垃圾评论,这些评论与待处理评论同时删除。
To delete all the pending comments, you need to type the required line of text into the box. You can copy and paste this text if you prefer.
要删除所有待处理的注释,您需要在框中键入所需的文本行。 您可以根据需要复制和粘贴此文本。
After that, go ahead and click the ‘Delete Pending Comments’ button.
之后,继续并点击“删除待处理评论”按钮。
You will then see a message confirming that all pending and spam comments have been deleted.
然后,您将看到一条消息,确认已删除所有待处理和垃圾邮件评论。
仅在WordPress中删除垃圾评论 (Deleting Spam Comments Only in WordPress)
What if you don’t want to delete pending comments but just want to delete the ones that are marked as spam? That’s very easy to do in WordPress.
如果您不想删除待处理的评论,而只想删除标记为垃圾邮件的评论该怎么办? 在WordPress中这很容易做到。
First, go to Comments in your WordPress admin and click on the Spam tab:
首先,在WordPress管理员中转到“评论”,然后单击“垃圾邮件”标签:
Next, click the Empty Spam button. This will delete all spam comments permanently, not just the ones on the current page:
接下来,单击“清空垃圾邮件”按钮。 这将永久删除所有垃圾邮件评论,而不仅仅是当前页面上的那些评论:
We hope this article helped you learn how to delete all pending comments in WordPress. You may also want to see our WordPress security guide to protect your website, or see our guide on how to allow users to report inappropriate comments in WordPress.
我们希望本文能帮助您学习如何删除WordPress中所有待处理的注释。 您可能还希望查看我们的WordPress安全指南以保护您的网站,或者查看有关如何允许用户报告WordPress中不当评论的指南 。
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.