Skip to content

Instantly share code, notes, and snippets.

@SiGaCode
Last active August 29, 2015 14:12
Show Gist options
  • Save SiGaCode/ba31bd5a46bdd89fba92 to your computer and use it in GitHub Desktop.
Save SiGaCode/ba31bd5a46bdd89fba92 to your computer and use it in GitHub Desktop.
This snippet comes in handy if you want to disable comments on attachment pages, got lots of media already and don´t want to go through each single one (no bulk edit here unfortunately). Credits: http://premium.wpmudev.org/blog/wordpress-comments-off/ Goes to Dynamik Custom - Functions
//* Don´t allow any comments on media attachment pages
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