The comment feature in WordPress is an essential component of blogs – but not in all cases it’s needed, especially if you use it as a traditional CMS.
Sure, you can just leave out the comment form while you creating a theme and disable the comment options in your backend. But this is not the best way for everyone. In such a case, I turn the comments off completely, making sure that the posts can not have that option and also remove the fields for the comments in the backend. That way the user gets exactly what he needs. Meanwhile, I have needed this so often that I created a small Plugin and I’m able to immediately „switch off“ the functions and comment areas. If there are major adaptations, I create them via Plugin or use my existing Plugin Adminimize.
One or the other will have some ideas or know some improvements for the Plugin – go to github and fork it or improve it, I would like to hear some feedback.
In the following screenshot I marked a few areas that are gone now. In the content editor of posts, pages or other post types the Metaboxes for comments, discussion and trackbacks are gone. More screenshots, what else is gone can be seen on my Repository.
Download link and links to the latest code are on github: Bueltge / Remove-Comments-Absolute. The following code is for a quick reading and represents only the first level. Updates or maintenance will take place on GitHub.
comment_status = 'closed'; $posts[0]->post_status = 'closed'; } return $posts; } /** * Close comments, if open * * @access public * @since 0.0.1 * @param string | boolean $open * @param string | integer $post_id * @eturn string $posts */ public function close_comments ( $open, $post_id ) { // if not open, than back if ( ! $open ) return $open; $post = get_post( $post_id ); if ( $post -> post_type ) // all post types return FALSE; return $open; } /** * Change options for dont use comments * Remove meta boxes on edit pages * Remove support on all post types for comments * * @access public * @since 0.0.1 * @uses update_option, get_post_types, remove_meta_box, remove_post_type_support * @return void */ public function remove_comments () { // int values foreach ( array( 'comments_notify', 'default_pingback_flag' ) as $option ) update_option( $option, 0 ); // string false foreach ( array( 'default_comment_status', 'default_ping_status' ) as $option ) update_option( $option, 'false' ); // all post types // alternative define an array( 'post', 'page' ) foreach ( get_post_types() as $post_type ) { // comment status remove_meta_box( 'commentstatusdiv', $post_type, 'normal' ); // remove trackbacks remove_meta_box( 'trackbacksdiv', $post_type, 'normal' ); // remove all comments/trackbacks from tabels remove_post_type_support( $post_type, 'comments' ); remove_post_type_support( $post_type, 'trackbacks' ); } // remove dashboard meta box for recents comments remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' ); } /** * Remove menu-entries * * @access public * @since 0.0.2 * @uses remove_meta_box, remove_post_type_support * @return void */ public function remove_menu_items () { // Remove menu entries with WP 3.1 and higher if ( function_exists( 'remove_menu_page' ) ) { remove_menu_page( 'edit-comments.php' ); remove_submenu_page( 'options-general.php', 'options-discussion.php' ); } else { // unset comments unset( $GLOBALS['menu'][25] ); // unset menuentry Discussion unset( $GLOBALS['submenu']['options-general.php'][25] ); } } /** * Add class for last menu entry with no 20 * * @access public * @since 0.0.1 * @param array string $menu * @return array string $menu */ function add_menu_classes ( $menu ) { $menu[20][4] .= ' menu-top-last'; return $menu; } /** * Remove areas for comments in backend via JS * * @access public * @since 0.0.1 * $return string with js */ public function remove_comments_areas () { ?> remove_menu( 'comments' ); } } // end class } // end if class exists ?>
Comments
16 responses to “Plugin to Remove Comments Completely from WordPress”
This is great – well done!
thanks, I was actually wishing for this type of plugin which makes a lot of sense to use on a site that doesn’t have a blog!
hey, I’m seeing this error on the frontend, on a custom single custom post type template :
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘Array’ was given in /home/…./public_html/deepfry/wp-includes/plugin.php on line 166
hey dude, steal your text, and do not mention
https://wpengineer.com/2230/removing-comments-absolutely-wordpress/
in spanish
http://translate.google.com.mx/translate?js=n&prev=_t&hl=es&ie=UTF-8&layout=2&eotf=1&sl=es&tl=en&u=http%3A%2F%2Fayudawordpress.com%2Feliminar-completamente-los-comentarios%2F
the site is:
http://ayudawordpress.com/eliminar-completamente-los-comentarios/
Thanks dude, I did leave a comment that they should leave a source, where the article is coming from.
Appreciate telling us!
@Paul: i have fixed this, was an cracy error of my mind 🙁 But please check always the status on github for updates and also add issues on github, its easy to track for all and for me. Thanks
thanks Frank, why don’t you host it on the WordPress repository?
@Paul: ist harder to publish on svn, git is realy better – but i have so much plugins on wp.org and its to much support for me; i have fear for to much plugins and support. Maybe i will do this and host on wp.org
You say it removes “completely”, but what about the comments feed associated with each post ?
<link rel="alternate" type="application/rss+xml"…
And what about the blog feed, which contains many tags ?
[…] Engineer has written a solid piece on removing WordPress comments from your blog, which is exceptionally helpful for those of us who run WordPress as a content […]
@george: Many Thanks – you have right; but now i have add a function to do this and also i open a ticket on WP Trac for change core; the plugin here add only all default feeds, without comments; but this also an small question in the core of WP, if the comments is inactive, than it is important to add not a comment feed.
Current use the last version on github and the feed is not include of head.
I installed the plugin. it seems to have removed some features, but all post have “closed for comments” And front page has # comments feature still showing- which is what I am trying to get rid of. Any advice?
@dan: These messages are controlled by your theme. The easiest way is to edit .CSS (style sheet) file of your theme, and to hide them:
#comments {display:none;}
.page .comments-closed {display:none;}
The names “#comments” and “.page .comments-closed” are just an example. In your web browser, look at the source code of your front page and post page, to determine the exact names to hide.
It’s a tricky one when you want certain comments to show and not others.. Good of you to grow WordPress -it keeps getting better as we specify the needs.
I will try this procedure on my blog. Thank you.
[…] auch im Backend (Admin-Bereich) die Kommentarfunktion nicht mehr haben möchte, der sollte sich das Plugin von Frank Bültge […]