Created
January 13, 2018 15:52
-
-
Save kopiro/17b192a9f2a480babb2c7b6160ee3a73 to your computer and use it in GitHub Desktop.
Remove comments in WP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('wp_loaded', function() { | |
remove_post_type_support('posts', 'comments'); | |
remove_post_type_support('posts', 'trackbacks'); | |
add_filter('comments_array', function() { return []; }, 20, 2 ); | |
add_filter('comments_open', function() { return false; }, 20, 2 ); | |
add_filter('pings_open', function() { return false; }, 20, 2 ); | |
if (is_admin()) { | |
add_action('admin_menu', function() { | |
remove_menu_page('edit-comments.php'); | |
remove_submenu_page('options-general.php', 'options-discussion.php'); | |
}, PHP_INT_MAX); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment