WordPress 3自定义帖子类型:如何获取评论

WordPress 3自定义帖子类型:如何获取评论,wordpress,comments,custom-post-type,Wordpress,Comments,Custom Post Type,我使用了4种自定义帖子类型,每种类型都有这种声明: register_post_type( 'texts', array( 'labels'=>array('name'=>'Texts','singular_name'=>'Text'), 'public'=>true, 'has_archive'=>true, 'menu_position'=>5 ) ); 我的问题是,这些页面中的帖子没有评论链接,说评论已经关闭 创建了一个

我使用了4种自定义帖子类型,每种类型都有这种声明:

register_post_type( 'texts', array(
    'labels'=>array('name'=>'Texts','singular_name'=>'Text'),
    'public'=>true,
    'has_archive'=>true,
    'menu_position'=>5
) );
我的问题是,这些页面中的帖子没有评论链接,说评论已经关闭

创建了一个名为text的页面,其中包含一段/text/,该页面有一个博客帖子的自定义模板,但它确实支持评论


我如何才能获得评论?请参见此处的“支持”参数,

或: 例如: 添加帖子类型支持('text','comments')

从我的主题的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/...
      )
    )
  );
}

你好,谢谢。我在数组参数中添加了对
register\u post\u type
函数的支持,但什么也没有发生。在wp admin中,我没有看到
允许评论
复选框,而在public部分,它只是说
评论已关闭。
。怎么了?嗨,在帖子编辑器页面的底部,每个帖子库也可以禁用/启用评论。是否为您的测试帖子启用了它?我使用这些参数(使用sd_register_post_type func):
'labels'=>数组('name'=>'News','singular_name'=>'News'),'rewrite'=>数组('slug'=>$post_type_slug,'with_front'=>false),'public'=>true,'hierarchical'=>false,'supports'=>数组('title'、'editor'、'author'、'thumbnail'、'trackbacks'、'custom-fields'、'comments'、'revisions')、'menu\u position'=>6、'capability\u type'=>post'
Hi,biziclop.你的评论不合适。:)你应该把它添加到你的答案中。嗨,我更新了上面的答案,希望你能从中找到有用的东西:)