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:
- Log into the backend of you WordPress Website
- Go to the “Media Library”
- Click on one of the media sources located in the “Media Library”
- 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!