I've hit the issue described in '11:

"Enable comments for post with comments meta box removed" and I'd like to ask for your help to adapt the mentioned there code to the current wordpress version.

I have a custom post type that must have comments enabled and contributors must not be able to disable comments.

I've enabled comments in Settings->Discussion and removed the commentstatusdiv meta box with remove_meta_box(). After that I've figured out that comments is unset when the meta box is disabled.

I am looking for the way to enforce the comments now.

1 Answer 1


Filter the 'comments_open' check. It happens inside of the function with the same name, and that function is called in a theme usually like this:

comments_open() and comment_form(
    array (
        'comment_notes_after' => ''

This is how the filter works:

add_filter( 'comments_open', 'wpse_98775_comment_check', 10, 2 ); 

function wpse_98775_comment_check( $open, $post_id )
    if ( $open )
        return $open;

    if ( 'my_post_type' === get_post_type( $post_id ) )
        return TRUE;

    return $open;

You could create a custom plugin with this snippet.

  • toscho, if not difficult, could you give a hint. 1. should this work with disabled commentstatusdiv meta box? 2. at what moment comments_open() fires? 3. code doesn't work for me. (I did change my_post_type to the desirable value)
    – Anton
    May 9, 2013 at 18:03
  • @anton See my update.
    – fuxia
    May 9, 2013 at 18:05
  • I have no problems with installation/setup, I've tried your snippet in functions.php, would it really make difference if I put it as a plugin?
    – Anton
    May 9, 2013 at 20:23
  • The comments_open() check happens in your theme. I have added an example. Make sure you are using a properly written theme.
    – fuxia
    May 9, 2013 at 22:48
  • 1
    thanks a lot for a theme hint. It was indeed an issue in the theme. Fixed now. And your snippet works flawlessly. THANKS.
    – Anton
    May 13, 2013 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.