The comment section on WordPress lets visitors talk to you and each other. But sometimes, you might not want comments everywhere on your site. Maybe you want to stop comments on pictures and other media attachments in WordPress.
Not everything needs a comment box.
In this guide, I’ll show you how to remove the comment box from media attachments and different types of posts in WordPress.
You can turn off all comments in the “General” settings, but this stops comments on everything. Maybe you just want to stop comments on images.
Why Have Comments at All?
Comments help you connect with your visitors. They make your website more fun and engaging. Comments can make people stay longer, come back more often, and even turn visitors into customers.
You can add tools to make comments even more interactive.
Worried about spam in the comments? Don’t be. WordPress has many ways to stop spam from becoming a problem.
Disable Comments Using WP Plugin
Today, I’ll show you what the “Disable Comments – Remove Comments & Stop Spam [Multi-Site Support]” plugin can do for you. It’s an easy plugin that allows you to turn off comments in WordPress according to section.
It’s perhaps one of the most popular disable comments plugins for WordPress. With over one million active installs and an excellent review score, it appears many treasure this tool.
However, depending on how you have media attachments set up on your website, it might not be exactly what you’re looking for. If this is the case, I’ll also include a code snippet later on that you might find useful instead.
Install and activate the “Disable Comments” plugin. You’ll see a couple of plugins with a similar name. Use the one by, “WPDeveloper.”
Go to Plugin > settings and click,
You’ll have two options available from this disable comments plugin in WordPress. You can turn off all comments by clicking “Everywhere,” or you can choose which post types by clicking the box.
Click the “Save Changes” button.
Disable Comments by Adding a Code Snippet
Although this plugin works exceptionally well, perhaps you want to add a snippet of code instead.
For this, you’ll need to insert coding into the site’s functions.php file or a site-specific plugin you have installed. For this tutorial, I’m simply going to add it to the functions.php file.
NOTE: It’s probably a good idea to use a child theme when making adjustments like this. You don’t want to add the code to disable comments on media attachments in WordPress only to have an update erase it.
Edit the functions.php file of your website. You can do this in several ways such as an FTP program like FileZilla, cPanel’s File Manager, or other methods that let you access the site’s root directory.
Add this code to the file
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 );
Note: if the code does not work kindly. improve it using chatgpt.com
In this example, I am using cPanel’s File Manager.
You can find the file by going to the “/wp-content/themes/” section of your site. Open the folder of the theme you’re using and edit the functions.php file.
Once you save the file, WordPress will turn off comments on media attachments throughout the website.
Not Everything Needs a Comment Section
You don’t need a comment section everywhere on your website. Sometimes, things like videos or images don’t need comments.
It’s easy to turn off comments on images and other attachments in WordPress. It depends on how you have your files saved and what you show to visitors.
How often do visitors leave comments on your site? Do you think having an interactive comment section makes people come back to your site more often?