How To Disable Comments And Comments Menu In WordPress

Hello wordpress developer in this tutorial i am going to show how to wordpress disable comments on pages using custom code. You can use plugin to disable wordpress comments on page. but for this simple thing i don't recommend plugin to disable wordpress remove comments from admin. 

In this post we will disable wordpress comments on existing posts and also disable or hiding comments menu from wordpress admin panel. After doing this simple thing you will see the comments section is disabled from your website for all the pages and post and categories.

So to disable leave a comment wordpress, just paste this below code in your theme functions.php.


// Close comments on the front-end
add_filter('comments_open', '__return_false', 20, 2);
add_filter('pings_open', '__return_false', 20, 2);


Now if you want to hide existing comments then paste this below code


// Hide existing comments
add_filter('comments_array', '__return_empty_array', 10, 2);


You can also remove comments page in menu.


add_action('admin_menu', function () {

// Remove comments links from admin bar
add_action('init', function () {
    if (is_admin_bar_showing()) {
        remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);


Hope it can help you.


#wordpress #custom-code