Disable wordpress comments

In WordPress you have the option to allow comments on your posts and pages. This can be a great way to encourage interaction with your visitors and create a sense of community on your website. However, there are times when you may prefer to disable the comments feature, for example, to prevent spam or to create a more professional atmosphere. In this tutorial we will explain how to disable WordPress comments.

Step by step guide to disable WordPress comments

  1. Log in to your WordPress dashboard. You can do this by going to your website URL and adding /wp-admin to the end.

  2. Navigate to ‘Settings’ > ‘Discussion’. Here you will see various options related to comments on your website.

  3. Disable the option ‘Allow link notifications from other blogs (pingbacks and trackbacks) on new articles’ and ‘Visitors can comment on posts’. Disabling these options will prevent comments and pingbacks from being allowed on future posts and pages.

Note: This will disable the comment function for future posts only. To disable comments for existing posts and pages, you need to edit each post or page individually and disable comments.

Disable comments for existing posts and pages with code

To disable comments for existing posts and pages, you can add the following code to the functions.php file of your theme or child theme:

					function disable_comments_post_types_support() {
    $post_types = get_post_types();
    foreach ($post_types as $post_type) {
        if(post_type_supports($post_type, 'comments')) {
            remove_post_type_support($post_type, 'comments');
add_action('admin_init', 'disable_comments_post_types_support');


This code disables comments for all post types on your WordPress website.

Simple solution with plugin: disable comments in WordPress effortlessly

This lightweight plugin is specially designed to efficiently disable comments in WordPress. It is reduced to the bare minimum and does not add any load to your website. A perfect solution for a quick and uncomplicated deactivation of the comment function.

Frequently asked questions

1. what does the code snippet do exactly?

This code will go through all post types on your WordPress website and remove support for comments. This means that the comment function will be disabled for all these post types.

2. does this code affect the existing comments?

No, this code only disables the ability to post new comments. All existing comments remain untouched.

3. how can I reactivate the comment function?

You can re-enable the commenting feature at any time by removing the above code from your functions.php file and re-enabling the options in ‘Settings’ > ‘Discussion’.

4. is it safe to make changes in the functions.php file?

Yes, it is safe as long as you are careful. Make sure you have a backup of your website

Scroll to Top