How to permanently disable comments in WordPress

Last updated December 6th, 2023 00:32

Comments on a website can be an effective way to gather feedback from users. They allow you to communicate with your community and exchange valuable information. However, despite this fact, there may be situations where comments are more of a hassle and not suitable for the website format. The good news is that using a snippet, they can be disabled. Permanently. In this article, you will learn how to permanently disable comments in WordPress using a snippet.

How to Permanently Disable Comments in WordPress Using a Snippet

You can completely disable comments in WordPress by adding a short code snippet using the WPCode plugin. I have personally been using this plugin for a while now, which is stored in the official repository and can be installed through your administration panel. You can find a complete guide on how to install and activate the plugin, as well as how to use it here: How to Add Custom Code to WordPress. So, first take a look at this article and install the plugin.

Snippet for permanently disabling comments

If you have already read my article on inserting custom code into WordPress, you can move on to the next step. You can now add the snippet that will completely disable all comments in WordPress. The snippet to copy is as follows:

					// Remove comments
add_action('admin_init', function () {
    // Redirect any user trying to access comments page
    global $pagenow;

    if ($pagenow === 'edit-comments.php') {

    // 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 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);

// Comments removed

After inserting and activating this snippet, comments will be deactivated both from the frontend, which is the website itself, and from the backend, which is the administration panel. Yes, even the comments section will disappear from the administration panel because it will no longer be needed.

How to permanently disable comments in WordPress using a snippet conclusion

As you can see, disabling comments is really not difficult for you. You don’t have to know how to program or have a deep understanding of how WordPress works. The snippet elegantly does everything for you and in a very safe way. You don’t even have to worry about accidentally breaking the WordPress files and having to restore them from backup.

More content about WordPress

Whole category is here

The website is created with care for the included information. I strive to provide high-quality and useful content that helps or inspires others. If you are satisfied with my work and would like to support me, you can do so through simple options.

Byl pro Vás tento článek užitečný?

Klikni na počet hvězd pro hlasování.

Průměrné hodnocení. 0 / 5. Počet hlasování: 0

Zatím nehodnoceno! Buďte první

Jak užitečný vidíte tento článek.

Sledujte mě na sociálních médiích.

Je mi líto, že pro Vás nebyl článek užitečný.

Jak mohu vylepšit článek?

Řekněte mi, jak jej mohu zlepšit.


Subscribe to the Newsletter

Stay informed! Join our newsletter subscription and be the first to receive the latest information directly to your email inbox. Follow updates, exclusive events, and inspiring content, all delivered straight to your email.

Upozornit na
0 Komentáře/ů
Vložené zpětné vazby.
Zobrazit všechny komentáře.

Pokud mi chcete napsat rychlou zprávu, využije, prosím, níže uvedený
kontaktní formulář. Děkuji.

Další Kontaktní údaje