Disable Comments on Media Attachments

Hack or Fix 22 views
0
0 Flares 0 Flares ×

Every media attachement gets its own page with its own comments section. This can by chaos with spam comments. To disable to comments on media attachments alone use this snippet.

<?php // how to disable comments on media attachments
function so_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', 'so_filter_media_comment_status', 10 , 2 );
Provided by: Piet Bos
Tagged with: ,
Posted in Wordpress

Discuss:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

No Trackbacks.

Login

Register | Lost your password?
0 Flares Twitter 0 Facebook 0 Google+ 0 0 Flares ×