I am using 4 Custom Post Types each having this kind of declaration:
register_post_type( 'texts', array(
'labels'=>array('name'=>'Texts','singular_name'=>'Text'),
'public'=>true,
'has_archive'=>true,
'menu_position'=>5
) );
The problem I have is that posts in these pages do not get Comment links, saying comments are closed.
There is a Page created called Texts with a slug of /texts/ which has a custom template for blog posts, but that does enable comments.
How can I get comments to work please?
See the 'supports' parameter here, http://codex.wordpress.org/Function_Reference/register_post_type
or: http://codex.wordpress.org/Function_Reference/add_post_type_support for example: add_post_type_support('texts','comments');
My example code, copied from my theme's functions.php:
// uses sd_register_post_type, which is from http://somadesign.ca/projects/smarter-custom-post-types/, not necessary anymore with WP3.1
add_action( 'init', 'create_post_types', 0 ); // before sd_register_post_type's actions
function create_post_types(){
$post_supports = array(
'title'
,'editor'
,'author'
,'thumbnail'
,'excerpt'
,'trackbacks'
,'custom-fields'
,'comments'
,'revisions'
);
$post_type_slug = 'my-news'; // max 20 chars!
$post_type_slug_plural = $post_type_slug;
sd_register_post_type( $post_type_slug, array(
'labels' => array(
'name' => 'My News',
'singular_name' => 'My New' // :)
)
,'rewrite' => array(
'slug' => $post_type_slug
,'with_front' => false // don't prepend /blog/...
)
,'public' => true
,'hierarchical' => false
,'supports' => $post_supports
,'menu_position' => 6
,'capability_type' => 'post'
),$post_type_slug_plural);
}
add_action( 'init', 'register_taxonomies_for_custom_post_types', 11 ); // 11=after sd_register_post_type's actions
function register_taxonomies_for_custom_post_types(){
$post_type_slug = 'my-news'; // max 20 chars!
register_taxonomy_for_object_type('category', $post_type_slug);
register_taxonomy_for_object_type('post_tag', $post_type_slug);
}
add_action( 'init', 'build_taxonomies', 0 );
function build_taxonomies(){
$post_types = array( 'post', /*'page',*/ 'my-news' );
register_taxonomy( 'city', $post_types,
array(
'public' => true
,'labels' => array(
'name' => 'Cities',
'singular_name' => 'City'
)
,'hierarchical' => true
,'rewrite' => array(
'slug' => 'my-news/cities'
,'with_front' => false // don't prepend /blog/...
)
)
);
}