我在网上有一个Wordpress网站。一些垃圾邮件发送者在我的Wordpress上发表了许多垃圾评论。我可以把wp_comments表放到我的Wordpress数据库中吗?我不想让任何人发表评论。当我删除wp_comments表时,Wordpress站点会崩溃吗?如果我删除wp_comments表,当有人在我的文章上写评论,然后点击发布它,在这种情况下,wordpress会崩溃吗?drop table wp_comments对我来说很好。
发布于 2014-08-01 21:26:39
这是我过去使用过的一段代码。它将重定向用户远离您的评论部分,并隐藏在您的后端的评论部分。选择您想要的片段,并将它们放在主题的functions.php文件中。
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
remove_post_type_support($post_type, 'trackbacks');
}
}
}
add_action('admin_init', 'df_disable_comments_post_types_support');
// Close comments on the front-end
function df_disable_comments_status() {
return false;
}
add_filter('comments_open', 'df_disable_comments_status', 20, 2);
add_filter('pings_open', 'df_disable_comments_status', 20, 2);
// Hide existing comments
function df_disable_comments_hide_existing_comments($comments) {
$comments = array();
return $comments;
}
add_filter('comments_array', 'df_disable_comments_hide_existing_comments', 10, 2);
// Remove comments page in menu
function df_disable_comments_admin_menu() {
remove_menu_page('edit-comments.php');
}
add_action('admin_menu', 'df_disable_comments_admin_menu');
// Redirect any user trying to access comments page
function df_disable_comments_admin_menu_redirect() {
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url()); exit;
}
}
add_action('admin_init', 'df_disable_comments_admin_menu_redirect');
// Remove comments metabox from dashboard
function df_disable_comments_dashboard() {
remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
}
add_action('admin_init', 'df_disable_comments_dashboard');
// Remove comments links from admin bar
function df_disable_comments_admin_bar() {
if (is_admin_bar_showing()) {
remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
}
}
add_action('init', 'df_disable_comments_admin_bar');发布于 2014-07-31 03:16:11
我建议你使用Akismet自动过滤那些可能是真实的评论,而99%的评论只是垃圾邮件链接到不可靠的网站,而不是从wordpress中删除评论表。
删除表有时会导致许多问题,..But使用像Akismet这样的插件将是防止垃圾评论的最佳解决方案。
发布于 2014-07-31 03:19:13
我可以想象,这会造成许多问题/错误。最好从插入注释的特定代码中禁用注释。
您可以在发现wp_insert_comment($data);的任何地方进行注释,这将允许您维护现有代码,以防有一天您希望它返回。
https://stackoverflow.com/questions/25050250
复制相似问题