Skip to content

Instantly share code, notes, and snippets.

@kopiro
Created January 13, 2018 15:52
Show Gist options
  • Save kopiro/17b192a9f2a480babb2c7b6160ee3a73 to your computer and use it in GitHub Desktop.
Save kopiro/17b192a9f2a480babb2c7b6160ee3a73 to your computer and use it in GitHub Desktop.
Remove comments in WP
<?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