Completely Disabling Comments in WordPress

This comprehensive code snippet disables all aspects of the commenting system in WordPress. It’s useful for websites that don’t require user comments, like business pages, portfolios, or landing pages. This approach not only hides the comments but also redirects any attempts to access the comments page, removes related widgets and links, and ensures no comments can be posted

Method 1 Code:

add_action('admin_init', function () {
    global $pagenow;
    if ($pagenow === 'edit-comments.php') {

    remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');

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

add_filter('comments_open', '__return_false', 20, 2);
add_filter('pings_open', '__return_false', 20, 2);

add_filter('comments_array', '__return_empty_array', 10, 2);

add_action('admin_menu', function () {

add_action('admin_bar_menu', function () {
    remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
}, 0);

Method 2 Settings:

Just go to wp-admin -> Discussions settings uncheck everything and enable the user to be registered easily. Personally, I do this most of the time.

Leave the first comment