WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

As per the documentation:

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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