This one.com guide will assist you in turning off comments on your WordPress website, providing methods for disabling comments on individual posts, pages, or your entire site.
- Why disable comments in WordPress?
- How to manually disable comments
- Disable comments on future posts
- Disable comments on a specific page or post
- Disable comments on pages and posts in bulk
- Delete all WordPress comments
- Disable WordPress comments using a plugin (WPCode)
Why disable comments in WordPress?
You may want to turn off comments on specific posts or pages or disable comments on your entire website for various reasons. For example, bloggers may not want comments on certain posts, and small business websites may not need them at all. Disabling comments can also help prevent spam. In WordPress, you can easily turn off comments or remove the comment section entirely.
How to manually disable comments
Please note that directly pasting code snippets into your theme files can easily break your site and is only recommended for advanced users. You can find alternative options in the sections below.
- Select your theme's functions.php file with the one.com File Manager.
- Click Edit in the pane to the right.
- Paste the provided code snippet at the end of the file:
add_action('admin_init', function () { // Redirect any user trying to access comments page global $pagenow; if ($pagenow === 'edit-comments.php') { wp_safe_redirect(admin_url()); exit; } // Remove comments metabox from dashboard remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal'); // Disable support for comments and trackbacks in post types foreach (get_post_types() as $post_type) { if (post_type_supports($post_type, 'comments')) { remove_post_type_support($post_type, 'comments'); remove_post_type_support($post_type, 'trackbacks'); } } }); // Close comments on the front-end add_filter('comments_open', '__return_false', 20, 2); add_filter('pings_open', '__return_false', 20, 2); // Hide existing comments add_filter('comments_array', '__return_empty_array', 10, 2); // Remove comments page in menu add_action('admin_menu', function () { remove_menu_page('edit-comments.php'); }); // Remove comments links from admin bar add_action('init', function () { if (is_admin_bar_showing()) { remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60); } });
- Click Save to save your changes.
- Done! This snippet redirects users trying to access the comments page, removes comments-related features, and closes comments on the front end.
Disable comments on future posts
If you're starting a new WordPress site, you can easily disable comments on future posts. Follow these steps:
- Go to Settings > Discussion in your WP Admin.
- Uncheck "Allow people to submit comments on new posts."
- Scroll down and click Save Changes to disable comments on future posts.
Disable comments on a specific page or post
By default, comments are disabled on all pages in WordPress. However, you have the freedom to enable or disable them on individual pages and posts.
- In your WP Admin, navigate to Pages > All pages.
- Hover your mouse over the page title to enable/disable comments.
- Click Edit under the desired page or post.
- Click on the Settings tab located on the right side of the editor.
- Then, find the Discussion box and uncheck "Allow Comments."
- Click on the Update button at the top next to the Settings tab.
Note: If you are unable to see it, you should check whether the Discussion box is enabled or not. On the top-right corner of your page, you will see a three vertical dots icon. Click on it to open a dropdown menu and select Preferences. Then, head to Panels and switch on the Discussion box.
You can follow the same process for turning off comments on individual posts:
WP Admin > Posts > All Posts > Edit.
Disable comments on pages and posts in bulk
Do you want to disable comments on all your published posts and pages at once, without using a plugin? Then follow these steps.
- Go to Posts > All Posts in your WP Admin and select the desired posts.
- Choose Edit from the Bulk Actions dropdown and click Apply.
- Set the comments dropdown to "Do not allow".
- Click Update to complete the process.
You can follow the same process for turning off comments on your pages:
WP Admin > Pages > All Pages > Edit.
Delete all WordPress comments
Although disabling comments on your WordPress site will prevent new comments from being added to your posts and pages, it will not remove any existing comments. To delete all the comments from your site, follow these steps:
- In your WP Admin, go to the Comments section.
- Choose "Move to Bin" from the Bulk Actions dropdown and click Apply.
- This process permanently deletes existing comments. If your website has a lot of comments, you may need to repeat this step multiple times since WordPress only displays a certain number of comments per page.
Disable WordPress comments using a plugin (WPCode)
As a last resort, we recommend using a plugin to disable comments, especially if your WordPress site is under attack by spambots. WPCode is a free plugin that can be used for this purpose.
- Log in to your WP Admin to install and activate the free WPCode plugin.
- Navigate to Code Snippets > Library in your WP Admin.
- Search for "completely disable comments" and use the corresponding code snippet by hovering over it.
- Click Edit snippet and WPCode will open the 'Edit Snippet' page.
- Toggle the switch on the right side to Active and click Update.
- That's it! This action removes all traces of comments from your site.
Related articles: