How To Disable Comments On A WordPress Website (No Plugin)

Published: 9 months ago

In this article, we're going to show you how to disable comments on a WordPress website without the need for a plugin.

The WordPress content management system was initially created for bloggers, and the commenting system was mandatory for that application. However, as it grew, many people began using it for other purposes like corporate websites, which don't need comments. In fact, if you keep comments enabled, you're opening yourself up to spam on these type of websites.

Because of that, it's important to understand how to disable comments on a WordPress website. There are many plugins that help you do just that, but if you are looking for a method that doesn't use a plugin (adding more bulk to your site) there's an easy code snippet that you can use. In this article, we're going to show you that code snippet, and how to implement it into your WordPress website, closing your comments, and eliminating any potential for spam.

Code Snippet To Disable WordPress Comments


add_action('admin_init', function () {
    // Redirect any user trying to access comments page
    global $pagenow;
    if ($pagenow === 'edit-comments.php') {

    // 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 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);

This code is sourced from this GitHub, and we highly recommend checking it out because there is some nice discussion, and additional snippets that you can use to disable other aspects of the commenting system on WordPress.

How To Use It

All you need to do is copy and paste the source code directly into a code snippet, or your functions.php file. For script management, we highly recommend the Advanced Scripts tool. Simply copy and paste the code into a new advanced scripts PHP snippet, and hook into the init.

If you use Advanced Scripts 2.0, you can download this file and import the script directly into your website. All you need to do is toggle it on, and you're good to go. No more comments on your WordPress website.

(download currently unavailable)

Another Method To Disable Comments (No Code)

You can also disable comments by going to the settings tab, discussions tab, disabling commenting there, and then bulk editing all your posts, and turning off commenting and pingbacks/trackbacks for each of them. More info on this method can be found here.

Why not a plugin?

There's nothing inherently wrong with using a plugin to disable WordPress comments, except for the fact that it is an incredibly simple thing to do with a code snippet, and any additional plugin adds bulk to a WordPress website. We prefer avoiding the use of plugins if at all possible, and this solution allows us to do just that. However, if you really want to use a plugin to disable comments on WordPress, this free offering from WPDeveloper works well:


We have used this method to disable all comments on a WordPress website for the past couple of years. This is a necessity if you aren't utilizing the blog functionality of the WordPress CMS, as it limits spam, and makes your website more secure.

Join Our Newsletter
Here's what you get: A once a week newsletter that contains original content, aggregated posts, WordPress deals, and anything else we think you'd like. We don't spam or sell your email address. Unsub at any time.
Notify of
Inline Feedbacks
View all comments
IsoGroup- Web Dev/Design, WordPress and More

Affiliate Disclosure: Some links on this website are affiliate links. We make commissions for purchases made through those links.

We only recommend items/tools that we've personally used and like.

Full Disclosure | FTC Statement

Join Our Newsletter
Over 4,000 Design Lovers and Problem Solvers.


A relationship driven website creation company.


© ISOTROPIC, LLC 2016-2021
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram