WordPress.org

Ready to get started?Download WordPress

Forums

disable comments for image files (6 posts)

  1. robgod
    Member
    Posted 6 years ago #

    I wish to allow comments on posts, but I have noticed that images I have added to my posts can allow comments aswell. i.e. Click an image and it opens a new page and allows a comment for that particular image.

    I have disabled comments for the post, but you can still add a comment for the image via the attahment page (e.g. "[website]/?attachment_id=18"). I cant find anything to disable "attachment" or image comments.

    How can I do it? (Even if it means amending code)... Most of the spam comes via this route!!

    Thanks
    Rob

  2. thecasualperfectionist
    Member
    Posted 6 years ago #

    Rob, I have this same question! Did you ever figure out how to turn off the comments on the images?

    Any information you have would be greatly appreciated.

    Thanks!

    ~Momma
    aka The Casual Perfectionist
    http://thecasualperfectionist.com

  3. flammable
    Member
    Posted 6 years ago #

    I've got the exact opposite problem. By default, I've got comments and pingbacks disabled (blog-wide), so every post and image has commenting turned off.

    I'd like to turn on commenting, but only for image galleries and images. However, I'd still like WordPress to have commenting off by default for everything else. Being able to toggle it per-item would be best.

    Wish I could help you guys, I'd trade places if I could. :)

    This sounds like it might need to be tweaked directly in the database, which doesn't thrill me. Mucking around in the database is just asking for trouble.

  4. Justin Tadlock
    Member
    Posted 6 years ago #

    For the first question, you should just remove this line from your image.php file.

    comments_template();

    This won't turn commenting off, but it won't allow people to comment simply because the form won't exist.

  5. flammable
    Member
    Posted 6 years ago #

    Okay, I managed to figure out how to enable or disable comments per images. Here's what you need to do.

    Warning: This is not for the faint of heart! Back up your database first, and make sure you understand what you're doing before trying this.

    Open up your database in PHPMyAdmin, and navigate to the wp_posts table. Click the 'Browse' tab at the top.

    Then, look for the entries that contain your images. I didn't leave captions on any of mine, so "post_content" was left empty. Another way of telling is that the "post_title" will be the name of your image file, such as untitled-28 or cimg1141.

    Click the pencil icon at the left of your post. Then, where it says "comment_status", change it from "open" to "closed" (or "closed" to "open" if you'd like to enable comments). Don't use the quotes, just input the word itself.

    Note: You can also adjust the "ping_status" if you want to enable/disable pings here, too.

    Scroll to the bottom of the page, and make sure it says 'Save' and then 'Go back to previous page'. Click the 'Go' button.

    Go back, find the image on your site, and the comment status should now be changed.

    I wish there was something to toggle this within the WordPress admin - or even a plugin to handle this. It's going to be time-consuming to edit every image I upload by hand.

    Heck, I'd even accept a MySQL query, I just don't know how to construct them.

  6. flammable
    Member
    Posted 6 years ago #

    Also, nice solution, greenshady. Definitely worth consideration. :)

Topic Closed

This topic has been closed to new replies.

About this Topic