How to disable comments in post WordPress 5 and higher

wordpress WordPress

If you decided to disable comments in post manually or programmatically (the causes of this need you can read in ‘What is the need to disable comments in posts WordPress‘) this article helped you to solve the issue.

Disable comments in posts in admin panel WordPress 5.0 and higher

So if you decided to disable comments in your blog manually for all posts you should do to following steps:

Find left panel ‘Settings’ and click on its subblock ‘Discussion’

There find ‘

When these manipulations took the place press ‘Save Changes’ button to set the new rules for the blog. And now all your new articles will be without comments block.

As you can mention while doing the previous steps, there is the notice that ‘(These settings may be overridden for individual articles.)’. That means you may leave comments in your blog but some articles have there own rules not to show comments.

The way of setting such rules are very simple, this rule is set in your article settings (when you writing the new one or is editing the old one). To disable comments for certain article manually in WordPress find in right setting panel  block ‘Discussion’, deselect ‘Allow Comments’ and save changes.

This unique rule will override all your previous rules that were made in bulk and will be used only for this article. If you need to have such rule for another post you should repeat the same with it.

Disabling comments programmatically in posts WordPress

If you decided to disable comments programmatically below you can find several decisions that helped to solve the issue.

Variant 1 of programmatically/dynamically disabling comments:

If you are using wp_insert_post for generating the posts, set the option ‘comment_status’ to ‘closed’ when inserting. This will make the rules for all posts in WordPress blog

And if you want change the status for disabling comments on existing post, use wp_update_post. In this case you will only need to send the post ID and the comment_status (two options: close or open).

Variant 2 of disabling comments in WordPress posts:

You should comment or erase some php code but better to comment to have ability to return comments in future.

Firstly find in page.php file the following code:

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

and comment it (replace to this code):

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

Secondly find in single.php file the code:

<?php comments_template(); ?>

and comment it (replace to this code):

<?php comments_template(); ?>
Variant 3 to disable comments in WordPress 5 and higher

This method is the easiest one but usually unnecessary. Just find the plugin and install it. But I do not recommend you to do this to solve the issue of this topic and that’s why don’t want to write about it though such ability is taking place.

That is all with our topic ‘How to disable comments in post WordPress 5 and higher’ if you still have any difficulties leave your questions in comments as I do not disable them 😉

Rate article
Add a comment