The commenting feature in the Graphene theme

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.