Sometimes we create sites for clients that either don’t have a blog section or do not want / need comments in that blog section. For those clients, I like to remove access to the comments in the admin menu and page / posts so it doesn’t clutter up the screen or confuse anyone. It only takes 3 actions / functions:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * COMMENTS * Remove comments in its entirety */ // Removes from admin menu add_action( 'admin_menu', 'nk_remove_admin_menus' ); function nk_remove_admin_menus() { remove_menu_page( 'edit-comments.php' ); } // Removes from post and pages add_action('init', 'nk_remove_comment_support', 100); function nk_remove_comment_support() { remove_post_type_support( 'post', 'comments' ); remove_post_type_support( 'page', 'comments' ); } // Removes from admin bar add_action( 'wp_before_admin_bar_render', 'nk_remove_comments_admin_bar' ); function nk_remove_comments_admin_bar() { global $wp_admin_bar; $wp_admin_bar->remove_menu('comments'); } |
These functions, in order, do the follow:
nk_remove_admin_menus: Removes the comments menu item from the main admin menu.
nk_remove_comment_support: Removes comments as a supported feature for the default page and post post-types.
nk_remove_comments_admin_bar: Removes the comments quick link on the admin bar that appear at the top of the front end when you are logged in
That should be make it very difficult for users to stumble upon comments / become confused by them. Enjoy!
Remove / Hide WordPress Comment Functionality in the Backend
Sometimes we create sites for clients that either don’t have a blog section or do not want / need comments in that blog section. For those clients, I like to remove access to the comments in the admin menu and page / posts so it doesn’t clutter up the screen or confuse anyone. It only takes 3 actions / functions:
These functions, in order, do the follow:
nk_remove_admin_menus: Removes the comments menu item from the main admin menu.
nk_remove_comment_support: Removes comments as a supported feature for the default page and post post-types.
nk_remove_comments_admin_bar: Removes the comments quick link on the admin bar that appear at the top of the front end when you are logged in
That should be make it very difficult for users to stumble upon comments / become confused by them. Enjoy!
Published in Wordpress