I am writing a plugin that upon activation, it creates a few new pages. On these pages, I want to disable the comments option. I am adding the new pages via the code below:

$page['post_type']     = 'page';
$page['post_status']   = 'publish';
$page['post_author']   = 1;
$page['post_parent']   = 0;
$page['post_title']    = 'Test Page';
$page['post_content']  = 'this is a test.  i want to disable the discussion option.';
$pageid = wp_insert_post($page);

In the WordPress codex, I do not see any option/property/meta to disable the Discussion section of a page/post. Does anyone know how?

1 Answer 1


As per the documentation:

$page['comment_status'] = 'closed'; // allowed values: 'closed' or 'open'
  • wow. Thanks so much for the answer. For some strange reason, I looked right over that attribute.
    – clockwiseq
    Apr 5, 2013 at 17:06

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.