How to disable WordPress comments?

Mujkanovic

Well-known member
Collaborate
Registered
Joined
Apr 24, 2016
Messages
424
Points
18
I got too many spams from comments on my wordpress blog. How can I disable WordPress comments completely? I don't want to open comments for posts any more. Any help?
 

Bryan McClure

Well-known member
Registered
Joined
Jul 20, 2016
Messages
271
Points
18
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.
 

Dreamwebhosts

Member
Hosting Provider
Registered
Joined
Dec 21, 2019
Messages
43
Points
6
Hide WordPress comment panels:-

To do that, go to Settings » Discussion from the left sidebar of your WordPress admin panel. On this page, you need to uncheck the option that says “Allow people to post comments on new articles” and then click on the Save Changes button to store your settings. This will disable comments on all your future posts.

The easier way to bulk disable comments on all media attachments is by using a code. Simply paste the following code in your theme’s functions.php file or a site-specific plugin.
--------------+
function filter_media_comment_status( $open, $post_id ) {
$post = get_post( $post_id );
if( $post->post_type == 'attachment' ) {
return false;
}
return $open;
}
add_filter( 'comments_open', 'filter_media_comment_status', 10 , 2 );
--------------+
 

Mujkanovic

Well-known member
Collaborate
Registered
Joined
Apr 24, 2016
Messages
424
Points
18
So many solutions to apply, I will try.

Thanks you guys!
 

Edward

Well-known member
Hosting Provider
Registered
Joined
Sep 1, 2018
Messages
109
Points
18

Akshay_M

Member
Registered
Joined
Nov 15, 2019
Messages
44
Points
8
You can enable/disable comments on future posts in your Discussion settings under My Site(s) → Manage → Settings.
Next, click on the Discussion tab.

Under “Default article settings,” toggle on/off the option to “Allow people to post comments on new articles.”
And you’re done!
 
Newer Threads
Recommended Threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top