Chapter 2: Enabling and disabling comments

While the ability to leave comments and interact with readers is integral to the way a standard blog works, it’s not nearly as important for an e-Commerce site. Unless you have a specific need for comments on your site (such as a business blog), you can disable them entirely. The following instructions will cover how to disable and remove all traces of comments on your site, but you’re free to follow only as much as you need, depending on how much customer interaction and feedback you wish to allow. For instance, you may wish to disable comments on WordPress pages, but not on posts, therefore leaving room for comments on a business blog. The choice is up to you.

Disabling Comments on Individual Posts/Pages

If you decide to leave comments enabled globally, you can still decide to disable them on individual posts and pages. After all, when we create our “Contact” page, how much sense does it make to leave comments enabled on that page? Not much.
To disable comments on individual posts and pages, look for the Discussion options when creating the desired post or page.

Un-check the boxes to Allow Comments and Allow Pings. Remember that this procedure must be done on a per-post or per-page basis.
Note: If you can’t find the discussion meta box make sure you have it enabled in the screen options

Disabling Comments Globally

If you wish to disable comments globally, first enter your WordPress admin panel and scroll down to the Settings option within the Dashboard and click the Discussion link.

Once the Discussion Settings page loads, look near the top of the page for the Default article settings. Un-check all the boxes that allow people to post comments, pingbacks, and trackbacks, and be sure to click the Save Changes button at the bottom of the page.

Removing Comment Traces From Your Theme

Though comments are now disabled, you may notice that your theme still contains references to comments by each post. For instance, our Crafty Cart theme still displays the option to Write Comment above each post.

You may also see lingering traces such as No Comments or Comments Off, depending upon your activated theme.
No problem. These traces are all easy to remove, though the instructions may differ slightly depending on your theme. First, go back to Appearance in your WordPress Dashboard and click the Editor link.

Next, look on the right side of the Dashboard under Theme Files for the files contained within the theme template. The file that we need to edit is called Single Post (single.php).

Note: please make a backup of your theme files before you edit them in case you make a mistake and wish to revert to the unedited version later.

The first thing we should do is remove the Write Comment link from any post using the Crafty Cart theme. Within the Single Post file for Crafty Cart, look for this passage of code:

[php]

<div class="post-footer">

<h4>

<span class="post-date"><?php the_time(‘F jS, Y’); ?></span>

<span class="post-comments"><a href="<?php comments_link(); ?>" title="See comments for this post">

<?php comments_number(‘Write Comment’,’1 Comment’,’% Comments’); ?></a></span>

<span class="post-category"><?php the_category(‘ &middot; ‘); ?></span>

<?php the_tags(‘<br/><span class="post-tags">Tags: ‘, ‘, ‘, ‘</span>’); ?>

</h4>

</div>
[/php]

What this code does is display the Date, the Write Comment link, and the post Category underneath the title of every post, just like in the previous Hello World picture. Notice that there are three items each contained within a span class: one for post-date, one for post-comments, and one for post-category.
If you delete the entire span class for the post-comments element (as highlighted above), you will remove the Write Comment link from all your posts.

Note: depending upon your theme, you may also need to repeat the above instructions on the Main Index Template (index.php).

Before you leave the Single Post page, also look for and delete this little snippet of code:
Deleting that code snippet will remove any traces of Comments Off or No Comments that appear in your theme. If your theme also has a Page Template (page.php), look for and delete that same bit of code there as well. By doing so, you will remove all traces of comments on any pages that you create within WordPress.
If you successfully followed these instructions, all traces of comments should now be erased from your theme.
Please take note: if you decide at any point to switch themes, you will have to repeat these steps for the newly activated theme.

Comments are closed.
KIWI