// Permanently disable comments in WordPress function disable_comments_everywhere() { // Disable support for comments and trackbacks on posts and pages remove_post_type_support('post', 'comments'); remove_post_type_support('post', 'trackbacks'); remove_post_type_support('page', 'comments'); remove_post_type_support('page', 'trackbacks'); } add_action('init', 'disable_comments_everywhere');
// Close comments on the front end 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);
// Remove comments page from admin menu function remove_comments_admin_menu() { remove_menu_page('edit-comments.php'); } add_action('admin_menu', 'remove_comments_admin_menu');
// Remove comments from admin bar function remove_comments_admin_bar() { global $wp_admin_bar; $wp_admin_bar->remove_menu('comments'); } add_action('wp_before_admin_bar_render', 'remove_comments_admin_bar');