Noticed that on a number of sites I’ve built the bulk of spam comments come from media file attachment pages. In this short tutorial, I’m going to show you how to turn off commenting on these files using a little bit of SQL.
WARNING: If you’re not comfortable working with databases, rather ask someone who is to do this for you.
How To
Fire up your favourite SQL editor and connect to your site’s database and run the query below. In most cases, this should involve using phpMyAdmin. I’m reluctant to go into too much detail here as those who should do this kind of stuff will know what I’m talking about.
Note: If you’ve changed your default table prefix from wp_ to something else, you’ll need to change the table name prefix to the same prefix you’ve used.
Turn Off Commenting Manually
Now, the problem with this solution is that unless you turn off commenting globally (from the WordPress dashboard got to Settings > Discussion and uncheck the “Allow people to post comments on new articles”), every time you upload new images, you’ll need to either run this query again or disable commenting manually on each image. To disable commenting manually, find the image in the WordPress Media Library and edit the image.
Once the Edit Media page has loaded for the image you will need to first display the Discussion box if it’s not already displayed. To do this, click on Screen Options at the top right hand side of the page and then click the checkbox next to the word Discussion.
Once you’ve done that, scroll to the bottom of the page and find the Discussion box and uncheck Allow Comments.
And now, all that’s left to do is to hit the Update button and you’re done.
Wrapping It Up
This isn’t the perfect solution to spam but it will at least stop spam comments on your images.
Divi Notes started as a way to document my own WordPress and Divi web design/development journey and, to my delight, has grown to become a helpful resource to many other Divi users out there. If you’ve found Divi Notes to be useful in your journey, I’d appreciate it if you would consider supporting me using the form below.
Thanks, it took me a while to figure out how this was happening. Most of my sites have comments disabled for post and pages, seems like you should have the ability to do this in settings also. What a pain! I did find a simple way to fix it if you don’t have users, just require the user to be logged in to make a comment.
Nice post it is very helpful hope to see more