Removing all comment functionality in WordPress

As more and more people adopt WordPress as a CMS, more and more of the original blog functionality is becoming redundant. Comments are one of.

Here is how to conclusively remove all comment functions in WordPress

add_action('init', 'kb_remove_comment_support');
add_action( 'admin_init', 'kb_remove_admin_menus' );
 
function kb_remove_comment_support() {
	remove_post_type_support( 'post', 'comments' );
	remove_post_type_support( 'page', 'comments' );
 
}
function kb_remove_admin_menus() {
	remove_menu_page( 'edit-comments.php' );
}

It uses two functions, the first one removes comment support from posts and pages. This means you dont have to uncheck “Allow Comments” on each post or page. It also removes the need to alter the Discussion settings.

The second function removes the Comments from the admin menu.

 

 

Author: Kieran Barnes

Kieran is a PHP developer with 15 years commercial experience. Specialist in WordPress, CakePHP, CubeCart and all things PHP.

1 thought on “Removing all comment functionality in WordPress”

  1. Thank you for this. However, I ran into a problem. Using admin_init was causing errors in plugins I was using. I changed it to admin_menu instead and everything works fine now. I know it’s 3 years later and things may have changed.

Leave a Reply

Your email address will not be published. Required fields are marked *