how to disable comments in WordPress on all posts

WordPress Disable Comments Sitewide: how to disable comments in WordPress on all posts

WordPress Disable Comments Sitewide: how to disable comments in WordPress on all posts

WordPress by default comes with an option of comments enabled on all posts and with a default comment message when you first install WordPress and for few website the comment section is unnecessary and website will be facing spamming issue with WordPress comment section enable. Here we are going to see how to turn off or WordPress disable comments sitewide here without any plugin and disable comments sitewide in WordPress with code adding in functions.php file.

We are going to turn off by using a simple function here which we will add in our functions.php file in WordPress. Functions.php file is very powerful file and it has all functions in it we can easily overwrite or change the functionality or add a new functionality or remove written functions by default WordPress disable comments and we can remove them and disable comments in wordpress and we can write as per our needs in WordPress functions.php file with simple code.

Disable comments in WordPress sitewide on all posts without Plugin:

There are several methods to do that and in which one of with the simple function we can achieve what we want here. We are disabling trackbacks and comments from wordpress without using plugin.

Here is the code to disable comments in wordpress sitewide:


// Keep in theme’s function.php file

// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_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');
			remove_post_type_support($post_type, 'trackbacks');
add_action('admin_init', 'df_disable_comments_post_types_support');

// Close comments on the front-end
function df_disable_comments_status() {
	return false;
add_filter('comments_open', 'df_disable_comments_status', 20, 2);
add_filter('pings_open', 'df_disable_comments_status', 20, 2);

Related Coverage:


1. How to Insert image in wordpress post and pages

2. Debug Mode WordPress: Disable and Enable Debug Mode in WordPress

3. WordPress Remove Uncategorized From URL

Disable Comments in WordPress With Plugins:

Download you functions.php file from server and make sure you keep your fucntions.php file backup and just copy and paste the above code in functions.php file and save it and upload it to server. Now when your functions.php file is updated with the above code and comments will be disabled and existing comments will be hided from wordpress website.

If you don’t wish to do it with the above code then there are plenty of wordpress plugins already available to disable comments.

Best Practice: You have to disable comments in wordpress and to do that you can use functions.php code or via plugins. If you are going with plugins extra code will be rendered and there may be problems with plugins, if any you will be land in trouble some times. If you can do it with code why use plugin