I've created a new custom post type for a specific posts. The posts from my new custom post type, have - by default - set the comments to "off". I need to the comments to be "on" by default.
In my functions.php
file I have this:
'supports' => array('editor','comments')
and
function default_comments_on( $data ) {
if( $data['post_type'] == 'registro' && $data['post_status'] == 'auto-draft' ) {
$data['comment_status'] = 1;
}
return $data;
}
add_filter( 'wp_insert_post_data', 'default_comments_on' );
But it didn't mark the box to comment by default. Any tips?
My default posts, don't show the metabox for comments, and the comments are allowed by default. I want to do exactly this with my new custom post type. I mean: Don't show the metabox and turn Comments on by default.
The register:
function create_post_type_registro() {
/**
* Labels customizados para o tipo de post
*
*/
$labels = array(
'name' => _x('Registros', 'post type general name'),
'singular_name' => _x('Registro', 'post type singular name'),
'add_new' => _x('Adicionar novo', 'film'),
'add_new_item' => __('Adicionar novo registro'),
'edit_item' => __('Editar registro'),
'new_item' => __('Novo registro'),
'all_items' => __('Todos os registros'),
'view_item' => __('Ver registro'),
'search_items' => __('Procurar registros'),
'not_found' => __('Nenhum registro encontrado'),
'not_found_in_trash' => __('Nenhum registro encontrado na lixeira'),
'parent_item_colon' => '',
'menu_name' => 'Registros'
);
/**
* Registamos o tipo de post registro através desta função
* passando-lhe os labels e parâmetros de controle.
*/
register_post_type( 'registro', array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'show_ui' => true,
'show_in_menu' => true,
'has_archive' => 'registros',
'rewrite' => array(
'slug' => 'registros',
'with_front' => false,
),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array('editor','comments')
)
);