The WPFolks app is out on iPhone and Android. Free, no ads. Download on the App Store Get it on Google Play
Skip to main content
Login Join
Snippet · PHP

Disable Comments Automatically for New WordPress Posts

Shared by Amit Dholiya · November 3, 2026

1 upvote
Back to Snippets

Steps

  1. Add the PHP code to your theme’s functions.php file or a PHP snippets plugin.

  2. Save and activate the snippet.

  3. New posts will have comments and pingbacks disabled by default.

/**
 * Disable comments and pingbacks for new posts
 */
function custom_disable_comments_for_new_posts() {
    update_option( 'default_comment_status', 'closed' );
    update_option( 'default_ping_status', 'closed' );
}
add_action( 'admin_init', 'custom_disable_comments_for_new_posts' );

Tested on

WordPress 6.8

Reported by the author on November 3, 2026. WPFolks has not verified this.

Not tested against WordPress 7.1.4. It may still work.

Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments

Proudly supported by