Disable Comments on Media

Comments can be a great way to interact with your Users and add some personality to your website by including your them in the conversation. However, you may not need the comments section for all features on your site.

In this article we will be focusing on how to remove the comment section from WordPress “Media” content

Where Are We Disabling Comments…?

The specific place we will be removing comments can be found through the following steps:

  1. Log into the backend of you WordPress Website
  2. Go to the “Media Library”
  3. Click on one of the media sources located in the “Media Library”
  4. Open the link titled “View attachment page”

steps 2-3

step 4

How To Disable Comments on Media

Go to the functions.php file located in the Theme folder of your WordPress website.

Add the following code to the bottom the the functions.php file:


function filter_media_comment_status( $open, $post_id ) {
$post = get_post( $post_id );
if( $post->post_type == 'attachment' ) {
return false;
}
return $open;
}
add_filter( 'comments_open', 'filter_media_comment_status', 10 , 2 );

Now sit back and relax knowing no one will be commenting on your Media anymore!