Removing the WordPress comments box from pages and posts

Overview

This article describes how to use built-in WordPress tools to remove the comments box from pages and posts.

Turning off comments on pages and posts

You can turn off comments to achieve either of the following, which are described in the following sections:

  • Option one: Comments won't appear on any new (or yet-to-be published) pages and posts
  • Option two: Additional comments won't appear on pages and posts that have already published

Option 1 — Disable comments on new pages and posts

The following steps disable comments for any new pages and posts you create:

  1. Open the WP-Admin panel for your WordPress site.
    2019-07_wp-admin_comments_spam_10.fw.png
  2. Click the 'Discussion' link under Settings in the left-side panel.
    The Discussion Settings dashboard opens showing you the following options:
    2019-07_wp-admin_comments_spam_11.fw.png
  3. Uncheck the 'Allow people to post comments on new articles' check box.

Option 2 — Disable comments on pages and posts that are already published

Use the following steps to disable comments to pages and posts that have already published:

  1. Open the WP-Admin panel for your WordPress site.
    2019-07_wp-admin_comments_spam_12.fw.png
  2. Click the 'All Pages' link under Pages in the left-side panel.
    The Pages dashboard opens showing you the following options:
    2019-07_wp-admin_comments_spam_13.fw.png
  3. Select all of the published pages by checking the check box directly next to 'Title' at the top.
    2019-07_wp-admin_comments_spam_14.fw.png
  4. Click the Bulk Actions drop-down box, select 'Edit', and then click the Apply button.
    The following Bulk Action display page opens:
    2019-07_wp-admin_comments_spam_17.fw.png
  5. In the Comments drop-down box, select 'Do not allow' and then click the Update button to save your changes.
  6. Repeat these steps for Posts as needed.

Turning off comments on pages only

WordPress allows you to disable comments on individual pages. The following steps show you how to use the Quick Edit link to make changes as well as how to make discussion options available on each page.

Using the Quick Edit link on individual pages

You can easily turn off comments on individual pages by clicking the 'Quick Edit' link under each page listing:

2019-07_wp-admin_comments_spam_16.fw.png

When the Quick Edit page opens, uncheck the 'Allow Comments' check box:

2019-07_wp-admin_comments_spam_18.fw.png

Enabling the Discussion option on pages

To enable 'Discussion' options to appear on pages:

  1. Open the WP-Admin panel for your WordPress site and open a page to edit.
    2019-07_wp-admin_comments_spam_19.fw.png
  2. Click the three vertical dots in the upper right corner and click the 'Option's link. This opens the Screen Options menu.
    2019-07_wp-admin_comments_spam_20.fw.png
  3. Make sure the 'Discussion' checkbox is checked.
    When you return to the page you're editing, click the gear icon in the upper right to view the page's settings:
    2019-07_wp-admin_comments_spam_21.fw.png
  4. Return to the page you're editing and click the gear icon in the upper right. Make sure the 'Allow Comments' checkbox is unchecked.

Making changes to WordPress source files

You can also make changes to your WordPress installation and source files located on your server (such as page template and theme files). For more information on how to edit files that are located on your server, see the following article:

Modifying page templates to permanently remove comments

The page template you use typically stores code that makes calls for comments to appear. You can remove this code from the template (or theme), which then disables comments from appearing on your pages.

Make sure you make a backup (aka, creating a "child theme") of your theme before making the following modifications.

To disable comments from appearing on the page template, open the page.php file in your theme folder. For example:

  • example.com/wp-content/themes/twentynineteen/page.php

Remove the following line:

<?php comments_template('', true); ?>

Adding a function to a theme that removes comments from a page

Make sure you remove any comments using one of the methods described above before adding the following code.

You can also add the following code to the functions.php file. This prevents comment support on your pages.

To remove comment support, add the following code to the functions.php file. Make sure to save it when finished:

//remove comments from pages
add_action('init', 'remove_comment_support', 100);

function remove_comment_support() {
remove_post_type_support( 'page', 'comments' );
}

See also

 

Did this article answer your questions?

Article last updated PST.