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'

Leave a Reply

Your email address will not be published. Required fields are marked *