核心代码:

//关闭评论
function close_comments( $posts ) {
    if ( !is_single() ) { return $posts; }
    $posts[0]->comment_status = 'closed';
    $posts[0]->ping_status    = 'closed';
    return $posts;
}
add_filter( 'the_posts', 'close_comments' );

- EOF -