How to Disable Comments in WordPress

Disable WordPress Comments

The comments, depending on the type of page you are going to have, can be really disturbing. If you have a blog you will want to allow comments, but if you have a business website you probably will not.

The comment function on WordPress post's is one of the most important and popular things in this content management system (CMS). It allows readers to comment, give their opinion, ask, and answer questions, on the other hand, allows the author to communicate with their readers. And this, in one way or another, enriches the content of your posts.

However, some people prefer to dispense with comments, and they want to completely remove the commenting feature on their blog, for various reasons.

In this post, I'll explain how to completely disable comments or remove it, even from the database. and other alternative options to close it or hide it. Also how to remove the comment tools in the administration panel.

Here are the different ways to manage comments in WordPress:

  1. From settings
  2. Manually on pages and posts
  3. With plugins
  4. With functions.php
  5. With database

Reasons to go without WordPress comments

There are many reasons some people wish to dispense with comments, and here are some causes:

  • For fear of the security risks that this implies.
  • Due to the lack of time to moderate these comments.
  • For fear of the inevitable trolls.
  • In cases of merely informative sites, in which the feedback of the opinions of the readers is not needed.

Risks of WordPress comments

The comment box is like an input window open to your blog's database.

You can secure it and put bars on it (Askimet) or other security measures, but as long as it is kept open, there is the possibility that someone can inject malicious code through it.

You should never think that your blog is completely safe, while you have the comment box or if you install improper plugins.

Some alternatives allow you to dispense with comments on your blog, and keep this feature, such as the Disqus service.

In this case, they have the open window and you only include the result in your blog.

You can also include the Facebook comment box. But the disadvantage in the case of Facebook is that the content of the comments does not enrich your posts in the eyes of search engines, who will only see the original content.

How to disable comments in WordPress

From Settings

To disable comments in WordPress, go to Settings > Discussion.

Screenshot comments setting in WordPress

Here deactivate the option Allow people to submit comments on new posts.

Also, you would disable the option Allow notifications from other blogs (pingbacks and trackbacks) on new posts.

This adds just a pingback to another website and gives it a link.

Manually on pages and posts

Well, if you already have comments published or you use a plugin, go to each of your pages and posts, and deactivate it manually.

For this, go to the comments section in the sidebar:

Screenshot discussion option post

If this option does not appear in the sidebar, go to the menu (3 vertical points) on the right top corner. Click on options, a small pop-up will appear and then check the Discussion box.

Options pop-up posts

With a plugin

Disable Comments plugin

Fortunately, there is a free nifty plugin that can disable your comments, the Disable Comments plugin. This gives you the opportunity to disable comments, either for your entire site or just on a per post basis.

Screenshot Disable Comments settings

When you want comments to be completely removed, the plugin will even make the comment form disappear. If you want to disable comments on a specific post, the comment form will be removed only on that post.

However, existing comments can remain, if you decide to keep them.

How to completely remove comments in WordPress

In the WordPress admin panel (Dashboard) options, there is no option to remove the comment box.

There are only some of them to customize this feature.

However, using the following method, which is extremely simple, you can completely disable the comment function in WordPress.

To do so, follow these steps:

  1. Open the file "comments.php" located inside the folder of the active theme.
  2. Edit it with a text editor (Notepad++ for example) and delete completely its content.
  3. Save the changes.

From that moment, the comment box will no longer be displayed on any page.

I recommend not editing this file but to copy it to a Child folder. That must be previously created, and then delete its content. If this is not done, WordPress updates will restore its original content.

Hide comment panels from WordPress Dashboard

If you decide to delete the comments, you can also hide the Comments section and the icon on the top bar from your administration panel.

For that, you must add the following instructions to the file "functions.php" in the Child folder of the active theme.

The following code hides the comment panel, which is accessed from the sidebar.

// Delete comment in admin panel (dashboard)
add_action ('admin_menu', 'my_remove_admin_menus');
function my_remove_admin_menus () {
    remove_menu_page ('edit-comments.php');

The following code removes the comments icon from the top bar of the Dashboard.

// Remove comment icons from the Dashboard bar
function mytheme_admin_bar_render () {
    global $ wp_admin_bar;
    $ wp_admin_bar-> remove_menu ('comments');
add_action ('wp_before_admin_bar_render', 'mytheme_admin_bar_render');

Other options to configure comments

Those who don't need to completely disable comments can use one of the following options.

Close comments

The first option closes the comments and displays the message “Comments are closed”, although the existing comments are displayed.

// Close comments and show: Comments are closed
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);

Hide comments

This option shows the message “Comments are closed” and hides the existing comments.

// Hide existing comments and show Comments are closed
function df_disable_comments_hide_existing_comments ($ comments) {
$ comments = array ();
 return $ comments;
add_filter ('comments_array', 'df_disable_comments_hide_existing_comments', 10, 2);

Hide comments without showing a message

This option is used with the previous one to hides existing comments without showing any messages.

// Hide comments and the comments message closed
add_action ('init', 'remove_comment_support', 100);
function remove_comment_support () {
    remove_post_type_support ('post', 'comments');
    remove_post_type_support ('page', 'comments');

However, with this method, an area of the page is kept blank, with the height of the hidden comment box. But it's possible to hide it using CSS.

How to remove comments from the database?

About those who have a large number of comments and want to permanently delete them from the blog's database, you can do it in two ways, using phpMyAdmin or the MySQL console.

Delete comments with phpMyAdmin

  1. Access phpMyAdmin from cPanel.
  2. Select the blog database in the side column.
  3. In the list of tables, find: "wp_comments"
  4. Use the Empty option.
  5. In the confirmation box: You are about to TRUNCATE an entire table! Do you really want to run “TRUNCATE‘ wp_comments ‘“?, press “OK”.

If the following tables are present, the same operation must be performed: "wp_commentmeta table" and "wp_transient_wc_count_comments".

Delete comments with MySQL

In the MySQL console enter:

TRUNCATE 'wp_commentmeta';
TRUNCATE 'wp_comments';

Feel free to drop me a line or ask any questions in the comments below!