• Resolved Lrrr

    (@lrrr)


    Hi, last time I read thread about turning off comments and no one in the forum understand what concerned user wanted do to, even he wrote it clearly several times. I was concerned also since I was solving the same issue (here’s the thread).

    So I google little and here is a clean solve how to have in creating (writing, editing) area default checked “allow comments” only when creating new post type, and have default unchecked when creating pages or uploading attachments.

    1: Here is (ext. article) an article which shows how to uncheck default comments on page type in WP.
    2: Understand, we do not want remove comments from any places, we just want to have “allow comments checkbox” unchecked in default when we creating pages or attachments.
    So, code mention in article, allows us to have comments open for all and for pages it will be in default unchecked=comments disabled. Still we can enable it on certain pages when editing.
    3: I dont know why, but for me did not work adding the $post_array['post_type'] === 'attachment' to mentioned code in point 2, so I solve it in opposite way:

    Disabling comments by default in admin>settings>comments and subsequently alowing the only post type to open comments, via code mentioned in article in point 2.

    You can add in your function file also code just before code mentioned in point 2:

    if ( get_option( 'default_comment_status' ) == 'open' ) {
            update_option( 'default_comment_status', 'closed' );
    }

    so you need not to disable comments in admin settings area manually.

    Finnaly we using modified (modified to enabling only for posts) code from article How to disable comments by default for new pages in WordPress after we disabled comments at all via admin>settings>comments 🙂

    Good luck 😉

  • The topic ‘turn off (checked off !) comments on pages by default’ is closed to new replies.