I am trying to add defualt comments to my custom post type.
I have added to my supports argument:
'supports' => array('title','editor','thumbnail','tags','post-formats','comments','revision'),
I've also tried a few functions like this:
function default_comments_on( $data ) {
if( $data['post_type'] == 'your_custom_post_name' ) {
$data['comment_status'] = 1;
}
return $data;
}
add_filter( 'wp_insert_post_data', 'default_comments_on' );
But nothing seems to work.Here is my custom post type:
function spark_register() {
$labels = array(
'name' => _x('Spark Garden', 'post type general name'),
'singular_name' => _x('Spark', 'post type singular name'),
'add_new' => _x('Add New Spark', 'sparknz'),
'add_new_item' => __('Add New Spark'),
'edit_item' => __('Edit Spark'),
'new_item' => __('New Spark'),
'view_item' => __('View Spark'),
'search_items' => __('Search Sparks'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'has_archive' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 8,
'supports' => array('title','editor','thumbnail','tags','post- formats','comments','revision'),
'taxonomies' => array('post_tag'),
);
register_post_type( 'spark' , $args );
}
add_action('init', 'spark_register');
I've tried adding to 'twentysixteen' and activating but that still doesn't show the comments by default. I have it checked to allow comments in my settings, it does appear in my regular 'post' post type, but in my cutom post type the discussion checkbox is not checked and comments are not showing by default?
Thanks in advance..