Skip to content

Instantly share code, notes, and snippets.

@designbuildtest
Last active August 29, 2015 14:01
Show Gist options
  • Save designbuildtest/4ae2c9206d74d14b185a to your computer and use it in GitHub Desktop.
Save designbuildtest/4ae2c9206d74d14b185a to your computer and use it in GitHub Desktop.
Disable WordPress Media Attachment Comments
<?php
/*
* http://www.wpbeginner.com/wp-tutorials/how-to-disable-comments-on-wordpress-media-attachments/
*/
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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment