Remove WordPress Comments Without Plugins


The comments on a WordPress blog are usually the focus of a site. Often, the remarks left by others on an article are more interesting than the post itself! However, there are many situations when you may want to remove WordPress comments or disable the comments entirely throughout the blog. Either you’ve determined that the comments are not adding any additional value (as some science-based sites have found), or you’re using WordPress not as a blog but as a site builder. Perhaps you wish to generate only press releases or some other content on which it doesn’t make sense to have comments.

For such situations, turning off comments not only makes sense, it also reduces the load on your website by eliminating all comment spammers. There are many ways to disable WordPress comments – you can use a plug-in, remove the comment section on a post by post basis by clicking the check box underneath every post’s editing screen, or by modifying the comments template for the theme.

Unfortunately, the first option requires you to add a permanent burden on your site by installing a plug-in. The second is not scalable for a large number of posts especially if you have a lot of backlog, and the third may be difficult to implement depending on the kind of theme you have.

Recently, many WordPress frameworks hide a lot of the internal workings of their themes making it nontrivial to find the appropriate theme file. However using one particular WordPress filter, we can implement a scalable solution for disabling comments on your WordPress site completely in a theme independent manner.
Creating an Empty File in Your Theme Folder

For this solution to work, we need to create an empty PHP file in the folder containing your theme. The easiest way to do this is to FTP in to your blog, create a blank PHP file on your desktop and transfer it over to the appropriate folder. You can use an FTP program like WinSCP for this purpose. In this example, I’m going to create an empty file called nothing.php:

create a file with nothing in it

It’s basically a blank notepad file renamed with a PHP extension. Open up your FTP program, navigate to your blog directory and then go to:


Make sure that it contains the “functions.php” file since we’re going to place some custom code into it and we want our references to work properly. Once the file is transferred, log into WordPress, go to “Appearance” on the left-hand side, and click “Edit”. this will bring you to the theme editor with the list of files on the right-hand side. Select functions.php as shown below and click the link:


Once it’s loaded into the text box, scroll all the way down and add the following code right at the very bottom:

function return_empty_comments( $emptyfile )
      $emptyfile = dirname( __FILE__ ). "/nothing.php";
       return $emptyfile ;
add_filter('comments_template', 'return_empty_comments');

how to remove WordPress comments without plugins

What this does is it creates a custom function to hook into the “comments_template” filter and simply returns the empty file we created in the first step. Note the “dirname()” function which returns the current path for the script, which is why it’s so important to place our nothing.php file into the correct subdirectory.

Save your functions.PHP file, locate any WordPress post or page containing a comments section and loaded up in your browser. Here is a before and after comparison of the comments section on my test blog.

Before Adding Custom Code:

create a website

After Adding Custom Code:

beginner tutorials

Note that this code in functions.php has to be copied over to every new theme that you implement. Each of them will have a functions.php file within their own sub directory so it’s not going to be very difficult to transfer it. If you want a more scalable solution, you can even create your own plug-in containing theme independent external code so that you don’t have to perform any additional migrations when switching themes. But that’s beyond the scope of this article.

This elegant technique can be further tweaked to only remove comments from posts, pages, or from those articles which don’t have existing comments on them. The latter option is useful if you want to retain all previous user generated content when you are creating a website.

Nick Anderson owns and operates which provides WordPress Web hosting products and add on’s.

About Michael John

Hi my name is Michael and I am here to help you create a website that works. If you require any help building your website please contact me. I am the owner of and would like to help you get online.

Please Share

Create An Online Shop

Build your own website and sell stuff. Add as many products as you want and it won't cost you any extra.

Get super fast hosting
Free domain registration
Outstanding reliability
Free shopping basket
Easy to use site builder

Try creating your website free for 30 days. No credit card required, click the below link.

Build and host your own website on super fast reliable hosting.

Free domain included or add a domain you own - Install WordPress in a few clicks - Great support team.

Get a Website that Works. It's quick and easy. No experience necessary.

Sign up today and get 20 percent off your hosting.