我之前写的《修改wp-comments-post 防垃圾(spam)评论》,是通过修改wp-comments-post文件名阻止垃圾评论机器人直接读取wp-comments-post文件,实现防垃圾留言。今天再续一个方法:将wp-comments-post文件移动到主题目录中达到阻止垃圾评论。
spam
同样需要修改程序文件:
一、首先打开Wordpress程序根目录的wp-comments-pos.php文件,用:
- ( dirname() . \’/../../../wp-load.php\’ );
替换第16行的:
- ( dirname() . \’/wp-load.php\’ );
之后,将 wp-comments-pos.php 文件移动到当前主题目录中。
二、再打开wordpress程序wp-includes目录的comment-template.php文件,用:
- <form action= method= id= =<?php ? \’ novalidate\’ : ; ?>>
替换第2046行的:
- <form action= method= id= =<?php ? \’ novalidate\’ : ; ?>>
三、如果主题使用的非WP标准表单函数,可以略过第二步,用:
- <form = method= id=>
替换类似:
- <form = method= id=>
注:WP标准表单函数为
- <?php comment_form(); ?>
另外,最好将wp-comments-pos.php文件也重新命名,并到后台讨论设置中设置评论超过个2超链接,移动到等审核中。
暂无评论内容