AI Verified

Name

Hide Comments on WP Dashboard

About

Completely hide the comments function in the Wordpress Dashboard

Language

PHP

Rating

Voted: 0 by 0 user(s)

Codevault

Commpany-Code-Snippets

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.1

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

Website/ Profile URL:

https://commpany.nl

History

Last modified:

01/02/2023

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Found 0 vulnerabilities

Hide Comments on WP Dashboard

 
                    
1add_action('admin_init', function () {
2 // Redirect any user trying to access comments page
3 global $pagenow;
4 
5 if ($pagenow === 'edit-comments.php') {
6 wp_safe_redirect(admin_url());
7 exit;
8 }
9 
10 // Remove comments metabox from dashboard
11 remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
12 
13 // Disable support for comments and trackbacks in post types
14 foreach (get_post_types() as $post_type) {
15 if (post_type_supports($post_type, 'comments')) {
16 remove_post_type_support($post_type, 'comments');
17 remove_post_type_support($post_type, 'trackbacks');
18 }
19 }
20});
21 
22// Close comments on the front-end
23add_filter('comments_open', '__return_false', 20, 2);
24add_filter('pings_open', '__return_false', 20, 2);
25 
26// Hide existing comments
27add_filter('comments_array', '__return_empty_array', 10, 2);
28 
29// Remove comments page in menu
30add_action('admin_menu', function () {
31 remove_menu_page('edit-comments.php');
32});
33 
34// Remove comments links from admin bar
35add_action('init', function () {
36 if (is_admin_bar_showing()) {
37 remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
38 }
39});

0

Related Snippets

Please see some snippets below related to this snippet..

WordPress Admin

AI Verified

0

Wordpress Updates

Added: 1 year ago

Last Updated: 1 year ago

See a list of Updates for Wordpress, Plugins, and Themes in the Dashboard.

WordPress Admin

AI Verified

0

Filter Posts by Author dropdown

Added: 1 month ago

Last Updated: 1 month ago

Adds a dropdown to the posts screen to filter by author

WordPress Admin

AI Verified

1

Add links to admin bar

Added: 1 year ago

Last Updated: 3 months ago

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

WordPress Admin

AI Verified

0

Hide WP Block Editor on specific post type

Added: 1 year ago

Last Updated: 1 year ago

Divi Builder

Unverified

0

Delete tooltips when hovering over images

Added: 1 year ago

Last Updated: 1 year ago

It annoys me a lot when having DIVI theme activated and you hover over an image, that the image name pops up in a tooltip. With this function you can hide that! Problem solved :)

WordPress Admin

AI Verified

0

Hide Comments on WP Dashboard

Added: 1 year ago

Last Updated: 1 year ago

Completely hide the comments function in the Wordpress Dashboard