There are various articles – to disable comments on WordPress.
If you are trying to disable it for a specific condition – this one is not for you.
If you want to disable “ALL” WordPress comments.
function disable_comment_2023(){
wp_die(new WP_Error(403, 'Comments have been temporarily disabled on the site'));
}
//do not allow comments
add_action( 'pre_comment_on_post', 'disable_comment_2023' );
Leave a Reply