Keeping Spam comments in check
Syllogic consultants champions a future where integral sustainable development is the norm, not the exception.

How to Disable Comments on WordPress Media Attachments

A lovely little piece of code to disable comments on Media Attachment pages which is a source of irritating SPAM…

Just paste the following in your 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 );

How to Disable Comments on WordPress Media Attachments.

Want to share your thoughts?

Leave a Reply

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