Skip to Content

“WordPress Comments are Closed” — Here’s How to Open Them

“WordPress Comments are Closed” — Here’s How to Open Them

Comments are a big part of building a community around your blog. Without comments being open, you’re having a one-way conversation.

To enable discussions on your blog, you need to enable the comments and keep them enabled.

By default, WordPress closes comments on posts older than 14 days and when this happens the “Leave a Reply” note at the end of the article will also disappear. Not good if you value comments and worked hard to get a lot of traffic to your articles. 

Discussion management is something you need to set up and manage consistently.

In this tutorial, you will learn the fastest way to globally enable comments, and moderate them efficiently.

 

How to open closed WordPress comments?

Within the discussion settings, you can change the duration for when WP closes comments on old posts. These can be managed with the quick edit options too. For multiple posts with comments closed, the fastest way is to run a SQL command line using PHPMyAdmin to open comments that have been closed.

 

Setting no expiration dates for comments

The default comment settings for WordPress is to close the discussion on posts older than 14 days.

To change this setting, go to the “Settings” tab in the left sidebar and select “discussion”.

The first section is how to open comments. Check the box to select “Allow people to submit comments on new posts”. This opens the comments.

The next section for “other comments settings” is where to change when comments are closed.

If you want your comments to always remain open, uncheck the box beside “Automatically close comments on posts older than 14 days”.

Do note that the “new posts” does actually mean that it only opens comments on new posts. It will not backdate to open comments on previously published posts.
 

Open comments on previously published posts with the quick edit option

To open comments on previously published posts and pages, use the quick edit option to manually open comments on a per-post or per-page basis.

An alternative is to open comments from within the WordPress post editor. Below the content area or in the right sidebar will be a discussion metabox.

You can check the box to “allow comments” and “allow trackbacks and pingbacks” if you want those.

If you do not see the discussion metabox, go to the top of the post and click the “screen options” tab in the top right corner below your profile.

This opens a drop-down menu where you can select all the editor options available to show below the content editor.

The “discussion” element is the one that shows the “enable comments” option. The “comments” element is to add a comment yourself beneath your post.
 

Open comments on previous posts by editing your WP database

When you have a lot of posts with the comments closed, manually enabling comments on a per-post basis is not practical.

The faster solution for that is to execute SQL command lines on your WP database.

Whether you use the native WordPress comment management system or integrate a third-party plugin to help moderate discussions, the process in the back-end remains the same.

Everything you do in the WP admin area writes a script to your WordPress database.

You can bypass everything (plugins and discussion settings) by editing your WP database directly using PHPMyAdmin.

Before you do, make sure to create a database backup. Everything that happens on your site is controlled by the database. Mess up the PHP scripts, your site will not function properly.
 

How to quickly create a backup of your WordPress database

Go to cPanel, select “WordPress Manager by Softaculous”. To the right of your domain, select the dropdown arrow. Scroll down and select the plus icon to show your database details.

Click the button that says “backup” and it will create a backup of your WordPress database installation.

To make changes to the database, click on the button to “view database”.

Within the database, select the “SQL” tab. This is where you can run various SQL command lines.

The SQL command to open comments that have been closed is

UPDATE wp_posts SET `comment_status` = ‘open’ WHERE comment_status = ‘closed’;

This will open comments on previously published posts that have had the comments closed due to reaching an expiration time set within the discussion tab – when the default was not changed from the default of 14 days.

To prevent spam attacks in your comments, you can opt for the safer option of only allowing registered users to comment.
https://maschituts.com/wp-admin/post.php?post=6236&action=edit&classic-editor__forget
The SQL command line for that is

UPDATE wp_posts SET comment_status = 'registered_only';

It should be noted that when you execute SQL commands, it applies globally to all posts and pages.

You can still overwrite these rules on an individual basis using the quick edit option for posts and pages, or alternatively with the discussion metabox below the content editor in WordPress.
 

Override closed comments rules using your Functions.php file.

You can also override closed comments rules within your Functions.php file.

Go to cPanel, open File Manager, load your theme folder (WP Content > Theme> Select your active theme) and open the functions.php file in edit mode.

Paste the following code into your functions.php file, toward the end.

function enable_comments_for_all(){
    global $wpdb;
    $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET comment_status = 'open'")); // Enable comments
    $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET ping_status = 'open'")); // Enable trackbacks
} enable_comments_for_all();

The reason this works is that the functions.php file loads every time your website loads. The only thing you need to do is clear the cache to see the changes take effect.

It will take effect for new users, but for returning visitors who have not cleared their browser cookies, they are shown a static cache version stored in the temp cookies in their browser.

Once changes are saved to the functions.php file, always clear your website cache for the changes to take effect.
 

Edit the comment status with the Code Snippets plugin

If you’re uncomfortable with editing the functions.php file or executing SQL command scripts, a simpler alternative is to use the Code Snippets plugin for WordPress.

Once installed and activated, a new menu item is added to your left sidebar labeled “Snippets”. Select “add new” and paste the code above that would be put into your functions.php file into the snippet editor.

Select the option to “Run snippet everywhere”, then scroll to the bottom and click on save changes and activate. This writes the code to your functions.php file and helps keep your snippets organized.

Having all your edits saved within the plugin helps you carry changes over to new themes, and avoids your custom codes being wiped out with WordPress updates to either the core installation files or by theme updates.