# Disable Comments Completely

> Turns comments off everywhere: closes comments and pings, hides existing comments, and removes the Comments menu, admin bar item and comment feed links.

- Type: PHP
- Runs: Run everywhere
- Category: [Disable Features](https://wpide.com/library/category/disable-features/)
- Tags: comments, disable, clean-up
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/disable-comments-completely/

## Code

```php
add_action( 'init', function () {
    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' );
        }
    }
}, 100 );

add_filter( 'comments_open', '__return_false', 20 );
add_filter( 'pings_open', '__return_false', 20 );
add_filter( 'comments_array', '__return_empty_array', 20 );
add_filter( 'feed_links_show_comments_feed', '__return_false' );

add_action( 'admin_menu', function () {
    remove_menu_page( 'edit-comments.php' );
} );

add_action( 'admin_init', function () {
    global $pagenow;

    if ( 'edit-comments.php' === $pagenow ) {
        wp_safe_redirect( admin_url() );
        exit;
    }
} );

add_action( 'admin_bar_menu', function ( $admin_bar ) {
    $admin_bar->remove_node( 'comments' );
}, 999 );

add_filter( 'wp_headers', function ( $headers ) {
    unset( $headers['X-Pingback'] );

    return $headers;
} );
```

## Notes

Existing comments stay in the database and come back if you deactivate the snippet.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Disable Comments Completely" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
