How to Enable and Disable Comments in WordPress

Updated on Jul 26, 2019

We all know that the WordPress platform has a feature that allows your users to write and read comments. However, not all webmasters who use WordPress to build their websites would prefer discussions allowed. Usually the main concern is the loading speed of the website as well as the admin dashboard. Spam is another concern for a lot of site owners and cutting the main source of spam is a welcomed change.

To learn how to manage the comment feature, follow these steps:

step

Good and Bad Reasons to Disable Comments in WordPress

Pros:

  • Gain more control by configuring a separate plugin like Disqus for managing interactions.
  • Prevent Spam/Bot comments which can clutter the database and increase load times.
  • Prevent phishing attempts to keep the user base safer, which is very useful on blogs related to cryptocurrency, finances, and real estate.
  • Prevent arbitrary code execution attempts via comments.
  • Move the communication over to social media, a dedicated forum, or community apps like discord.

Cons:

  • Completely removing comments from a community based websites can be detrimental.
  • Some visitors might find it annoying if they don't have a way to provide feedback.

Note

You can enable/disable comments only for specific posts or pages via its individual "discussion" settings.

In this tutorial, among other things, we will show you how you can enable or disable the comments on your website for all future posts, disable existing comments individually and in bulk as well as removing comments from attachments

If you want to learn more about this part of the configuration on your website, check our other tutorial called "How to Manage Comments in WordPress."

step

How to Disable Comments in WordPress using Standard Dashboard Settings

For most webmasters, the options already provided by the core platform are more than enough for managing the ways their users can comment on their content. In the next sub-steps we will show you how to disable comments individually and in bulk and even how to remove the ability of users to have discussions on media files in posts.

Enable and Disable Comments for Future Posts

To begin, you will have to log in your site's admin area and navigate to Setting → Discussion.

Access the Discussion Settings in WordPress

Once you access that section, you will notice a lot of different options. Don't get intimidated, as for this one we will only need the "Allow people to post comments on new articles" field. The same can be found at the first set of settings on that page.

Enable or Disable Comments on New Articles

For more information on the rest of the settings, visit our "How to Configure your Settings in WordPress" tutorial.

Please check/uncheck this option if you would like to enable or disable the comments on your website. Once you are done with that change scroll down to the bottom of the page and hit the Save Changes button.

Disable Comments on Selected Posts (or pages) in Bulk

Disabling comments on future posts will not remove the user's ability to leave comments on already existing posts. Furthermore, if you have a lot of posts, entering the editing options for each of them one by one can take you quite a while. In this case, you can utilize the bulk editing feature of WordPress. Enter the All Posts section and select the posts which you want to edit. Then click on the Bulk Action drop-down menu and select Edit followed by a click on Apply.

Disable Comments in Bulk

That will bring the main post options which you will be able to change for all of the selected posts at once. Select Do not allow for the comments field and hit Update.

Stop Comments on Existing Posts Individually

If you only want to switch comments off for specific posts far in-between, you can do that individually per post. Access the edit post interface and make sure you have enabled Discussion from the Screen Options menu.

Enable the Discussion Screen Options

That will show the Allow comments field which you can uncheck, thus stopping the comments on this post.

Disable Comments on Individual Posts

Make sure to hit the Update button before you exit.

Disable Comments on Media Files

A lot of people users are not aware that WordPress has a feature for leaving comments on media files like pictures and videos. Furthermore, there are bots specifically made in order to abuse that feature which makes media comments a possible security issue. To disable the comments on a media file, first enter the Media Library section of your Dashboard and click on the Edit option of the file you want to secure. 

Edit Media Attachments in WordPress

Again, find the Allow Comments checkbox and uncheck it.

Disable Comments in Media Files

step

How to Disable Comments with a Plugin

You don’t want to get your hands dirty with all of the nitty-gritty comment options in the different parts of your website? Adding one more plugin to your dashboard is not an issue for you? In that case, using the Disable Comments plugin will save you a lot of trouble. This plugin is created with only purpose in mind - to disable all possible way a comment can get published on your website.

Add the Disable Comments Plugin to WordPress

Once installed, you will have the option to globally disable all discussions going as far as doing that in an entire multisite installation network. The other option is to stop comments in one of the specific commentable elements in your website - posts, pages, or media.

Configure the Disable Comments Plugin in WordPress

step

How to Disable Comments with Code

Depending on your theme, you can also disable commenting with a code snippet inserted directly into some of your WordPress files

Warning

Editing WordPress files can lead to errors or complete failure to load your website. Not recommended for beginners!

Navigate to the File Manager via your cPanel. Then access the location of your WordPress installation, which will usually be /home/youruser/public_html/wp-includes and click the edit button on the functions.php file.

Then add this after the 1st line which is the opening <?php tag:

add_action('admin_init', function () {
    // Redirect any user trying to access comments page
    global $pagenow;

    if ($pagenow === 'edit-comments.php') {
        wp_redirect(admin_url());
        exit;
    }

    // Remove comments metabox from dashboard
    remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');

    // Disable support for comments and trackbacks in post types
    foreach (get_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');
        }
    }
});

// Close comments on the front-end
add_filter('comments_open', '__return_false', 20, 2);
add_filter('pings_open', '__return_false', 20, 2);

// Hide existing comments
add_filter('comments_array', '__return_empty_array', 10, 2);

// Remove comments page in menu
add_action('admin_menu', function () {
    remove_menu_page('edit-comments.php');
});

// Remove comments links from admin bar
add_action('init', function () {
    if (is_admin_bar_showing()) {
        remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
    }
});

As you can see, you have comments on each of the added limitations explaining the exact effect. This will help you if you want to retain some functionality while removing other.

Congratulations! Upon completing this tutorial, you now know how to modify the configuration for the comments on your site!

On this page...

    WordPress Hosting

    • Free WordPress Installation
    • 24/7 WordPress Support
    • Free Domain Transfer
    • Hack-free Protection
    • Fast SSD Storage
    • Free WordPress Transfer
    • Free CloudFlare CDN
    • Immediate Activation
    View More