Skip to main content
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
Source Link

You can re-register the "page" post type and leave out the comments capability.

add_action( 'init', 'my_new_page_type' );

function my_new_page_type() {
    register_post_type( 'page', array(
        'labels' => array(
            'name_admin_bar' => _x( 'Page', 'add new on admin bar' ),
        ),
        'public' => true,
        'publicly_queryable' => false,
        '_builtin' => true, /* internal use only. don't use this when registering your own post type. */
        '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
        'capability_type' => 'page',
        'map_meta_cap' => true,
        'hierarchical' => true,
        'rewrite' => false,
        'query_var' => false,
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'revisions' ),
    ) );
}

###Actual answer: original source hereoriginal source here

function default_comments_off( $data ) {
    if( $data['post_type'] == 'page' && $data['post_status'] == 'auto-draft' ) {
        $data['comment_status'] = 0;
        $data['ping_status'] = 0;
    }

    return $data;
}
add_filter( 'wp_insert_post_data', 'default_comments_off' );

You can re-register the "page" post type and leave out the comments capability.

add_action( 'init', 'my_new_page_type' );

function my_new_page_type() {
    register_post_type( 'page', array(
        'labels' => array(
            'name_admin_bar' => _x( 'Page', 'add new on admin bar' ),
        ),
        'public' => true,
        'publicly_queryable' => false,
        '_builtin' => true, /* internal use only. don't use this when registering your own post type. */
        '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
        'capability_type' => 'page',
        'map_meta_cap' => true,
        'hierarchical' => true,
        'rewrite' => false,
        'query_var' => false,
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'revisions' ),
    ) );
}

###Actual answer: original source here

function default_comments_off( $data ) {
    if( $data['post_type'] == 'page' && $data['post_status'] == 'auto-draft' ) {
        $data['comment_status'] = 0;
        $data['ping_status'] = 0;
    }

    return $data;
}
add_filter( 'wp_insert_post_data', 'default_comments_off' );

You can re-register the "page" post type and leave out the comments capability.

add_action( 'init', 'my_new_page_type' );

function my_new_page_type() {
    register_post_type( 'page', array(
        'labels' => array(
            'name_admin_bar' => _x( 'Page', 'add new on admin bar' ),
        ),
        'public' => true,
        'publicly_queryable' => false,
        '_builtin' => true, /* internal use only. don't use this when registering your own post type. */
        '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
        'capability_type' => 'page',
        'map_meta_cap' => true,
        'hierarchical' => true,
        'rewrite' => false,
        'query_var' => false,
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'revisions' ),
    ) );
}

###Actual answer: original source here

function default_comments_off( $data ) {
    if( $data['post_type'] == 'page' && $data['post_status'] == 'auto-draft' ) {
        $data['comment_status'] = 0;
        $data['ping_status'] = 0;
    }

    return $data;
}
add_filter( 'wp_insert_post_data', 'default_comments_off' );
added 497 characters in body
Source Link
Adam
  • 16.5k
  • 1
  • 44
  • 62

You can re-register the "page" post type and leave out the comments capability.

add_action( 'init', 'my_new_page_type' );

function my_new_page_type() {
    register_post_type( 'page', array(
        'labels' => array(
            'name_admin_bar' => _x( 'Page', 'add new on admin bar' ),
        ),
        'public' => true,
        'publicly_queryable' => false,
        '_builtin' => true, /* internal use only. don't use this when registering your own post type. */
        '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
        'capability_type' => 'page',
        'map_meta_cap' => true,
        'hierarchical' => true,
        'rewrite' => false,
        'query_var' => false,
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'revisions' ),
    ) );
}

###Actual answer: original source here

function default_comments_off( $data ) {
    if( $data['post_type'] == 'page' && $data['post_status'] == 'auto-draft' ) {
        $data['comment_status'] = 0;
        $data['ping_status'] = 0;
    }

    return $data;
}
add_filter( 'wp_insert_post_data', 'default_comments_off' );

You can re-register the "page" post type and leave out the comments capability.

add_action( 'init', 'my_new_page_type' );

function my_new_page_type() {
    register_post_type( 'page', array(
        'labels' => array(
            'name_admin_bar' => _x( 'Page', 'add new on admin bar' ),
        ),
        'public' => true,
        'publicly_queryable' => false,
        '_builtin' => true, /* internal use only. don't use this when registering your own post type. */
        '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
        'capability_type' => 'page',
        'map_meta_cap' => true,
        'hierarchical' => true,
        'rewrite' => false,
        'query_var' => false,
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'revisions' ),
    ) );
}

You can re-register the "page" post type and leave out the comments capability.

add_action( 'init', 'my_new_page_type' );

function my_new_page_type() {
    register_post_type( 'page', array(
        'labels' => array(
            'name_admin_bar' => _x( 'Page', 'add new on admin bar' ),
        ),
        'public' => true,
        'publicly_queryable' => false,
        '_builtin' => true, /* internal use only. don't use this when registering your own post type. */
        '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
        'capability_type' => 'page',
        'map_meta_cap' => true,
        'hierarchical' => true,
        'rewrite' => false,
        'query_var' => false,
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'revisions' ),
    ) );
}

###Actual answer: original source here

function default_comments_off( $data ) {
    if( $data['post_type'] == 'page' && $data['post_status'] == 'auto-draft' ) {
        $data['comment_status'] = 0;
        $data['ping_status'] = 0;
    }

    return $data;
}
add_filter( 'wp_insert_post_data', 'default_comments_off' );
Source Link
developdaly
  • 1.8k
  • 2
  • 19
  • 33

You can re-register the "page" post type and leave out the comments capability.

add_action( 'init', 'my_new_page_type' );

function my_new_page_type() {
    register_post_type( 'page', array(
        'labels' => array(
            'name_admin_bar' => _x( 'Page', 'add new on admin bar' ),
        ),
        'public' => true,
        'publicly_queryable' => false,
        '_builtin' => true, /* internal use only. don't use this when registering your own post type. */
        '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
        'capability_type' => 'page',
        'map_meta_cap' => true,
        'hierarchical' => true,
        'rewrite' => false,
        'query_var' => false,
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'revisions' ),
    ) );
}