I will explain how to completely disable it and other alternate options to close or hide comments.
The comment feature in WordPress
The function of commenting on WordPress is one of the most important and popular of this publishing system.
It allows readers to comment, give their opinion, ask questions and answer them and the author to communicate with the readers.
All of them in one way or another enrich the content of the publications.
However, some people prefer to disable comments for various reasons.
Reasons to disable with WordPress comments
Some wish to disable comments for some of the following reasons:
- For fear of the security risks involved.
- Due to the lack of time to moderate these comments.
- For fear of the inevitable trolls.
- In cases of merely informative sites, where feedback from user opinions is not required.
How to completely delete comments in WordPress
In the options of the administration panel of WordPress, no option is included to remove the comment box.
There are only several ways to customize this function.
However, using the following method that is extremely simple, you can completely disable the commenting feature in WordPress.
Do the following steps:
1/ Open the file “comments.php” located inside the folder of the active topic.
2/ Edit it with a text editor (It can be Windows Notepad) and erase its contents completely.
3/ Save the changes.
From now, the comment box will no longer be displayed on any page.
Hide WordPress comment panels
If we decide to delete the comments, we can additionally hide the Comments panel and the icon in the top bar from our administration panel.
For that we must add the following instructions to the “functions.php” file in theme folder.
The following code hides the comments panel, which is accessed from the sidebar.
Code:
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 in the top bar.
Code:
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 close or hide comments
Close comments
The first option closes the comments and displays the message "Comments closed", although the existing comments are displayed.
Code:
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
The next option shows the message "Comments closed" and hides existing comments.
Code:
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 message
The next option, if used with the previous one, hides existing comments without displaying any messages.
Code:
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 a blank page area is maintained, with the height of the hidden comment box.
I hope it helped.