Completely disable WordPress comments
WordPress is gaining more and more popularity these days, especially since version 3.0 that added a lot of features that make WordPress capable of functioning more and more as a Content Management System apart from being primarily a blogging software.
One of the features that is often not required in a non-blog website is the Discussion feature, or probably more widely known as the commenting feature. While this feature forms the very basis of social engagement in a blog and one of the most important features, it is nevertheless often unneeded in a corporate website that serves to disseminate information rather than having a lively discussion about its services.
The easiest (but superficial) solution
As a result, I’ve been asked a few times by the users of my WordPress theme, Graphene, on how to disable the commenting feature completely. Initially, the obvious (and easiest) solution to this is simply to hide the entire comment section of the theme using CSS. While this does the job, it isn’t exactly the best solution. The markup of the comment section is still there, and the browser still needs to load it, and a whole load of PHP functions and database queries still need to be done, even though the result is not visible to the end user.
The (much) better solution
Then I thought of a better solution that completely removes the (now unnecessary and extraneous) executions of the PHP functions that load the comment feature. The solution is notoriously simple, by taking advantage of WordPress’ awesome templating system and a child theme.
What you need to do is just create a child theme, and create a new comments.php file inside the child theme. Then, insert this code in the comments.php file you just created:
<?php return false; ?>
After that, all you need to do is activate the new child theme that you have created. That’s it, and the comments listing display and comment form will be completely removed from the theme you’re using. And it should also work with all themes that conform to the standard WordPress templating structure.
How I love child themes.


28 comments
Robert said
January 19, 2011 at 10:58 am (UTC 12)
I don’t want to disable comments, but rather not show them. Is there a way to close the comment list on a page?
Can’t seem to find a setting.
Thanks
http://holidaysforfamily.com
Syahir Hakim said
January 19, 2011 at 3:15 pm (UTC 12)
The above tips does not actually disable the WordPress’ comment functionality per se, but merely forces the theme to not load the comment functionality.
If you don’t want comments to be displayed on a page, at the bottom of the Edit Page screen there’s an option to disable comments and pingbacks/trackbacks. Depending on the theme that you use, the comment section may or may not be displayed when commenting is disabled.
carolyn said
March 25, 2011 at 11:22 am (UTC 12)
Hi Syahir:
I love your theme however when I added two new pages the ability to not have comments on those pages was not an option any more. I would like to continue using your theme for business websites, not blogs and I can not have the comment section on these websites. Please advise.
Thanks in advance.
Carolyn
tommyz said
March 25, 2011 at 1:17 pm (UTC 12)
hi Carolyn
I believe what you are referring to here is a wordpress 3.1 feature that by default hides some of the backend widgets. to see the discussion option widget again, edit the page, and in the top right corner, click on screen options, there you need to select Discussion and then walla, the widget will again appear.
this thread is about disabling the comments completely in WordPress.
anyway let me know if you have other questions
Carolyn said
March 26, 2011 at 2:46 am (UTC 12)
Hi Tommy: Thank you for answering my question however, I followed your instructions until the point where I could not find anywhere where it says “screen options.” Can you be more specific?
The ability to keep or turn off comments was on every single page and post previously. You could turn that off with two check marks. When I upgraded, that completely went away. I don’t think it has to do with hidden widgets.
Carolyn
Paul Poole said
October 1, 2011 at 3:09 am (UTC 12)
I recently loaded your Graphene theme. I also heard that there was an update but I can not find the specifics of the update.
Would you be so kind as to direct me to where the details of the update are listed….please. I am very new to all this so forgive me this question. Where would you place banner advertisements in your theme? I tried to put them in a text box but they come out off center to the left.
Thanks for your time Syahir.
baadtaste said
February 9, 2011 at 6:12 am (UTC 12)
Hi
I have made a slider with only images, and would like to disable comments on the slider/images in the slider – I would also like to completely hide the “read full story” button. (it is located in the top right corner and is visible if you mouse over it) Here is the link to the temporary site-adress. (you might not recognize your theme?):
http://companystories.no/blog/
Thank you for your continued work.
ps
this should perhaps have been put in the support forums?
kyle H said
February 15, 2011 at 12:33 pm (UTC 12)
Hello,
I just sent a message to you, but not sure if you’ll respond here or there.
The disable comments and ping back function doesn’t seem to be there after updating this last time and although my old pages haven’t changed setting I can’t remove the comments form from individual pages as before. Any help?
Thanks,
Kyle Horne
Jesus Acapulco Jr said
March 4, 2011 at 2:43 am (UTC 12)
Hi there Syahir Hakim,
I am also experiencing the same problem like kyle is. The option for disabling the comments and ping back at the bottom part of editing the pages is gone.
Can you help us please?
Big Thanks,
Jesus Antonio
Kelly said
March 5, 2011 at 9:15 am (UTC 12)
Since the new update, I’m having a problem with the lining up of images in my posts. With images aligned right, the second paragraph of text drops below the image, rather than staying aligned to the left. (You can click my link to see what I’m talking about)
kellydb said
March 5, 2011 at 10:20 am (UTC 12)
Never mind me just above – I’ve found the support forum and posted there.
Kim said
March 7, 2011 at 10:45 pm (UTC 12)
why do i see a “no ping yet” next to the number of comments on all my pages now?
Andrew Green said
March 9, 2011 at 11:06 pm (UTC 12)
Hi,
Great Theme!
I have not been able to remove the post’s, i tried the childs theme a couple of times. I am not a code wiz and still have not been able to work it out. Is the a button in the WP panel that can disable posts with this theme?
Thanks
tommyz said
March 10, 2011 at 11:23 am (UTC 12)
Hi Khairul
I get this error trying this method with Graphene 1.2.1
I created comments.php with nothing but <?php return false; ?> in it.
The error I get is:
Parse error: syntax error, unexpected T_STRING in ***/wp-content/themes/graphene-child/comments.php on line 10
Any ideas?
tommyz said
March 17, 2011 at 9:22 am (UTC 12)
ok i guess i had to give it a proper header/body tag as well and now it works fine.
the code:
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>comments off</title>
</head>
<body>
<?php return false; ?>
</body>
</html>
[/code]
Comment page: 1 2 3 / Next