Removing Comments from Pages WordPress
Comments are an essential part of any blog. Comments on pages, however, are not necessary and often times intrusive to the overall design. It may seem at first that their is no easy way to turn off comments on pages. That may be the case, but before you turn to a plugin to solve this problem, let’s dig into the code instead.
To navigate to your WordPress website’s code, make sure that you are an admin and hover over “Appearance” in the side menu. From the drop down list, choose “Editor.” Inside this editor lives the core files of your website. Look through the list on the left hand side of the screen and find the link titled “page.php” and click on it.
Inside this file is the PHP which acts dynamically to fill each page of your website with the relevant content. The overall makeup of this page is very simple and straight forward. Their is a header, a loop (content call), sidebar call, comment call and finally footer call. We want to locate the comment call and eliminate it.
Scroll down through the code and find the piece of code that looks like this <?php comments_template(); ?> and cut it to your clipboard. Hit the big blue “Update File” button at the bottom of the page. Now go back to your pages and see if the comments are still showing through. If there are any errors as you navigate through the site, go back to where you copied out the code and paste it back in and save. This should fix back the error.
If your comments are gone, however, then congratulations!
BONUS: Don’t throw away that handy little piece of PHP code: <?php comments_template(); ?>
It can be used anywhere inside of your other PHP files to add a comments area. Try a comments field in your index.php or footer.php file. These may not be that attractive of options either, but it can be fun to experiment.
Have you had success adding or removing comments on your site? Tell us about it in the comments!
Leave a Reply
Want to join the discussion?Feel free to contribute!