您可以重新注册“页面”帖子类型并省去评论功能。
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\' ),
) );
}
实际答案:
original source herefunction 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\' );