Comments allowed on media?

I have been getting the occasional mysterious spam comment, even though I always disable comments throughout my whole site. Took me a while to track down, but I have just discovered that a visitor can comment on a media item. Huh??? I never knew this was even possible.

Apparently this is enabled by default, and so I now have a site with many hundreds of images that all have comments enabled. And there seems to be no easy way to do a bulk change of this. Do I need to run an sql command on the database?

And who thought this was a good idea in the first place? :thinking:

WordPress did. Dumb, to put it simply.
There must be a function or filter to disable that.

1 Like

Try this little snippetydoodah:

function disable_media_comments( $open, $post_id ) {
  $post = get_post( $post_id );
  if( $post->post_type == 'attachment' ) {
    return false;
  return $open;
add_filter( 'comments_open', 'disable_media_comments', 10 , 2 );

Thanks Tim! That will be going into my utility plugin for ALL sites.


You can have a look to disable any content.

It just disable every comment and add a menu to bulk remove existing ones.


Thank you Tim, Handy snippet, I’ll borrow that as well.
I (almost) always make sure comments are turned off before adding any a site so problem does not arise.
If client wants comments just allow on a per post basis

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.