Last active
August 26, 2020 00:56
-
-
Save junaidbhura/4d3701513a3167677a318c0151ab5dd0 to your computer and use it in GitHub Desktop.
WordPress remove comments globally
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Remove support for comments globally. | |
*/ | |
function jb_remove_comment_support() { | |
add_filter( 'comments_open', '__return_false' ); | |
add_filter( 'pings_open', '__return_false' ); | |
$post_types = get_post_types(); | |
if ( ! empty( $post_types ) ) { | |
foreach ( $post_types as $post_type ) { | |
remove_post_type_support( $post_type, 'comments' ); | |
remove_post_type_support( $post_type, 'trackbacks' ); | |
} | |
} | |
add_action( | |
'admin_menu', | |
function () { | |
remove_menu_page( 'edit-comments.php' ); | |
} | |
); | |
} | |
add_action( 'init', 'jb_remove_comment_support' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment