29 May 2013
Comments: Comments Off on When You Need WordPress Comments to Really, Completely, Totally Stop

When You Need WordPress Comments to Really, Completely, Totally Stop

WordPress comments make me think of Rasputin, the 19th century Russian mystic.

The story goes that when his enemies wanted to kill Rasputin, they stabbed him, but he survived it. So they poisoned him with a large amount of cyanide – and he survived that too. Shooting him in the back with a revolver slowed him down temporarily, but then suddenly he rose up and lunged at his attackers. They shot him again, and then clubbed him repeatedly, and somehow he still lived. Throwing him into an icy river finally put an end to poor Rasputin.

WordPress comments can be almost as hard to kill off, but I’m going to tell you exactly how.

Photo of Rasputin
Grigori Rasputin, 1869-1916, got on the wrong side of some people

Start with the Settings > Discussion Screen

The first thing to do is to start with the Discussion settings.

Screenshot of Dashboard menu
In the Dashboard under Settings > Discussion is a list of checkbox options for controlling comments throughout the site.

There are a number of useful settings on this screen. However, there is no option, or even combination of options, which will completely prevent comments (and their relatives — pingbacks and trackbacks) from being submitted on a site where comments have already been allowed on some posts. It would be great if there was; maybe a future version of WordPress will include it.

Help! Immediate First-Aid

The option An administrator must always approve the comment will prevent all comments from being published on the front-end of the website unless they are approved by someone with the proper user role. But of course this will allow comments to appear in the Dashboard in the Moderation Queue, where they will need to be dealt with on a regular basis, and so this is only a stop-gap measure to prevent the public from seeing them, as a quick first-aid measure.

Screenshot of one Discussion screen setting
Quick first aid

Step 1: Protecting all future posts

The two most important options on the Settings > Discussion screen for our purposes apply only to posts published in the future. Those two options are Allow link notifications from other blogs (pingbacks and trackbacks) and Allow people to post comments on new articles. Un-checking both of these options will protect all of your future posts from allowing comments, pingbacks and trackbacks.

Screenshot of Discussion settings

Unchecking these two options will ensure that comments will be automatically turned off, but only on posts you create in the future.

To begin to solve our stated problem, you should definitely uncheck both of those options, and Save. That will protect you on future posts. But it won’t do anything to stop the flow of comments, pingbacks and trackbacks on currently published posts.

Please note that the term posts includes WordPress pages, which are a type of post, as well as custom post types.

A Note on Avoiding This Mess in the First Place

On a brand-new WordPress site, before any posts have been created, making sure that the two options just discussed are unchecked will completely prevent this mess in the first place. That’s the ideal solution. But for now, our concern is an established site with posts which have already been open to comments.

Pingbacks and Trackbacks

Although pingbacks and trackbacks are not comments in the true sense of that word, they are close relatives in that they can be submitted by the public, and appear in the same locations on the website and in the Dashboard. The term comments is often used to refer to all three. However, disabling all three requires taking steps for true comments as well as pingbacks and trackbacks.

In the Dashboard, on the main Comments screen, the list of Comments can be sorted so that you can see which are which type by clicking the down-arrow beside Show all comment types and making a selection. Note that Pings includes both pingbacks and trackbacks.

Screenshot of Comments list
Sort the list on the Comments screen to see which are regular comments and which are pingbacks or trackbacks.

Step 2: Closing Off Comments on All Individual Posts

Our next step is to close off comments on all existing individual posts.

On each post’s Edit Post screen, there is a box with the label Discussion.

Screenshot of Discussion settings box
A Discussion settings box is available on the Edit Post screen.

If you don’t see that box, go to Screen Options at the very top of the screen, click the down arrow, and make sure Discussion is checked.

Screenshot of Screen Options
If you don’t see the Discussion box on the Edit Post screen, look at the top of the page for the very useful Screen Options.

In the Discussion box, you can uncheck both Allow comments and Allow trackbacks and pingbacks on this page. Be sure to Save. If you only have a small number of posts, this step won’t take long.

But what if you have dozens, hundreds, or thousands of posts where this setting needs to be changed? Fortunately, WordPress’ Bulk Actions functionality will make this a lot easier.

Bulk Actions is found on the Posts screen, where the list of posts is shown. Follow these steps to make changes to the comments, trackbacks and pingbacks options on a number of pages in one process:

    • Check the checkbox at the top left, above the list, to select all of the posts on the screen. (Or instead, if you prefer, check only the individual posts you want to bulk edit.)
    • Click the down-arrow next to Bulk Actions, and choose Edit.
Screenshot of Bulk Actions function
WordPress’ Bulk Actions feature is a huge time-saver, allowing you to make changes to certain settings on multiple posts at the same time. Before choosing Bulk Actions > Edit, select the posts you want to edit using the checkboxes provided.
    • Click Apply. A Bulk Edit section appears with a limited set of settings available.
Screenshot of the Bulk Edit options
  • Click the down-arrow next to Comments and choose Do not allow.
  • Click the down-arrow next to Pings and choose Do not allow.
  • Click Update to save these changes.

The Posts screen shows 20 posts by default. If you have a large number of posts where these settings need to be changed, you’ll want to change that number. Go to Screen Options, change the number 20 to a higher number, and click Apply. In my tests, WordPress failed on bulk editing 200 posts, but was able to manage it with 150, but the exact number may depend upon your server environment or Internet connection.

Screenshot of Screen Options
Change the number of posts which appear on a single screen in the Dashboard’s Posts list.

When you’ve changed the Discussion settings on all of your individual posts, you’ll need to do the same for all of your individual pages, if you’ve allowed comments on pages, by following the same steps. However, there is a significant difference when bulk-editing pages – the pingbacks and trackbacks setting simply isn’t provided. That setting must be changed on every page, one by one, or you may continue to receive pingbacks and trackbacks on your existing pages.

Step 3: Comments on Attachment Pages

Photo of Rasputin making a WordPress spam comment
Watch out! He’s lunging at you!

So Step 1 and Step 2 have been carefully taken. Rasputin has got to be dead, right? But to your amazement, he rises up and lunges at you! Your site is still receiving comments!

This is because WordPress attachment pages can receive comments, pingbacks and trackbacks.

Each time a media item is attached to a post, an attachment page is created. If this is done when the options are enabled in Settings > Discussion to allow comments, that attachment page will allow these to be submitted. Depending upon the theme, site visitors and spammers may have the opportunity to submit a comment, pingback or trackback to the attachment page itself.

Attachment pages have an Edit Media screen, very similar to the Edit Post screen discussed above. To view attachment pages, go to Media > Library, where you’ll find a list of all media items which have been uploaded via the WordPress Media Uploader. At the top of the list, click “All” to display all media items, whether they are images or other types of media.

Screenshot of the Media Library page
Of course, media items aren’t only images. On the Media Library screen, the list of items can be sorted using links at the top of the list.

Notice the column with the heading “Uploaded to,” which shows that some media items have been uploaded to, and attached to, a specific page or post, which is identified. Other images may be “Unattached.” I point this out because all images have an attachment page, whether they are attached to a post or not.

Screenshot of Media Library list
To edit the attachment page of a media item, click the Edit link beneath its name.

The Edit Media screen for each individual media item is accessed by clicking the Edit link beneath the item’s title. And from the Edit Media screen, clicking View Attachment Page opens the front-end attachment page, where a comment form can be seen, assuming comments are enabled for that page.

Screenshot of Edit Media page
View the front-end attachment page.

But let’s stay on the Edit Media screen. Just like the Edit Post screen we talked about previously, it displays a Discussion box, providing the ability to check or uncheck Allow comments and Allow trackbacks and pingbacks on this item. To disallow them, you will need to uncheck these options and Save. Unfortunately, there is no Bulk Edit function for attachment pages, so this will need to be done on each Edit Media screen, one by one.

If you have a large number of media attachment pages set to allow comments, pingbacks and trackbacks, this may be impractical.

However, the fix is easy, even without a plugin. It involves a simple code edit to a theme file. You can do this from within the Dashboard by going to Appearance > Editor and locating and editing “Theme Functions (functions.php)”.

When you need to edit a theme file directly, it can be done through the Dashboard. Just be sure to make a backup first.

If you prefer, you can download the file via FTP, edit it locally with a code editor or a program like Notepad, and upload it.

Before you edit any theme file, be sure that you have a good backup of it. Then open the file, scroll to the very bottom, and copy-paste the following code block just after the last line:

function filter_media_comment_status( $open, $post_id ) {
$post = get_post( $post_id );
if( $post->post_type == 'attachment' ) {
return false;
return $open;
add_filter( 'comments_open', 'filter_media_comment_status', 10 , 2 );

Save the file, and if you’re working locally, upload it to the server.

Keep in mind that if you’re using a third-party theme without employing a child theme, and in the future you install an updated version from the theme author, this change will be overwritten.

A Plugin Solution

This article has shown how to completely disable comments on a site where existing posts have been accepting comments, entirely through the Dashboard. Another solution for the problem is offered by a plugin which may work well for you. If you want to go this route, be aware that any plugin may conflict with your theme’s code or with other plugins, either now or in the future. Also keep in mind that a plugin may not be maintained as new WordPress versions are released.

Screenshot of the Disable Comments plugin's entry on WordPress.org

The plugin Disable Comments allows site administrators to globally disable all comments, including pingbacks and trackbacks. Comments can be disabled for specific post types only – posts, pages, or attachment pages. The plugin’s effects are reversible simply by disabling the checked options.

Screenshot of Disable Comments plugin
The plugin Disable Comments allows you to disable all comments, or choose only certain types of posts. Its actions are completely reversible, with the exception of the feature called Persistent Mode.

It also automatically does the following:

  • Removes all comment-related fields from edit and quick-edit screens
  • Removes comment-related items from the Dashboard, Widgets, the Admin Menu and the Admin Bar.

Disable Comments also includes an option called Persistent Mode which, unlike the default use of the plugin, makes changes to the database and is not easily reversible. Persistent Mode was added to address a specific situation in which a theme has been coded so that it doesn’t correctly check the comment status of posts. Persistent Mode should not be used unless necessary, since reversing it will require you to manually edit the WordPress database.

The plugin worked smoothly in my tests with WordPress 3.5.1. As of this writing, its compatibility stats also reflect this; it has been recently updated, has good approval ratings, and support forum problems having nearly all been resolved. But please check these factors before using this or any plugin.

The Future?

Hopefully, future versions of WordPress will simplify the task of entirely disallowing comments on an established site. But meanwhile, whether you handle the process via the Dashboard or with a plugin, comments can be really, completely, totally stopped.

Image Credits: Wikimedia Commons, Wikimedia Commons

Related posts:

  1. Get a Handle on WordPress Comments with Comments Control Want to kill those annoying messages you get when posting…
  2. Close WordPress Comments With 1 Click Want to speedily close or open comments on posts? This…
  3. Encourage Comments by Displaying Visitors Who Leave the Most Comments This plugin will increase comments by rewarding those who leave…

Comments are closed.