Skip to content
// Disable comments and trackbacks everywhere
function disable_all_comments() {
// Disable comments
add_filter('comments_open', '__return_false', 20, 2);
add_filter('pings_open', '__return_false', 20, 2);
// Hide existing comments
add_filter('comments_array', '__return_empty_array', 10, 2);
}
add_action('init', 'disable_all_comments');
// Remove comments-related admin menu
function remove_comments_menu() {
remove_menu_page('edit-comments.php');
}
add_action('admin_menu', 'remove_comments_menu');
// Remove comment support from posts/pages
function remove_comment_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');
}
if (post_type_supports($post_type, 'trackbacks')) {
remove_post_type_support($post_type, 'trackbacks');
}
}
}
add_action('init', 'remove_comment_support');