WordPress的3自定义文章类型:如何获得评论

问题描述:

我使用4种自定义文章类型每个都具有这样的声明: register_post_type('texts',array('labels'=>array('name'=>'Texts','singular_name'=>'Text'),'public'=>true,'has_archive'=>true,'menu_position'=>5));WordPress的3自定义文章类型:如何获得评论

我的问题是,在这些网页的帖子没有得到评论的链接,说评论被关闭。

有一个Page创建了一个叫做Texts的文本,其中包含一个/ texts /,它有一个博客文章的自定义模板,但它确实启用了注释。

请问我该如何评价工作?

参见这里的 '载体' 参数, http://codex.wordpress.org/Function_Reference/register_post_type

或: http://codex.wordpress.org/Function_Reference/add_post_type_support 例如: add_post_type_support( '文本', '注释');

我的示例代码,从我的主题的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/... 
    ) 
    ) 
); 
} 
+0

你好,谢谢。我在'register_post_type'函数的数组参数中添加了支持,但没有任何反应。在wp-admin中,我没有看到“允许评论”复选框,而在公开部分,它只是说'评论已关闭。“。怎么了? – Francisc 2011-03-17 14:27:25

+1

嗨,评论可以被禁用/启用每个帖子的基地,在帖子编辑器页面的底部。它是否启用了您的测试帖子? ('name'=>'News','singular_name'=>'News') ,'rewrite'=>数组('蛞蝓” => $ post_type_slug, 'with_front'=>假) , '公共'=>真 , '分层'=>假 '载体'=>数组( '标题' '编辑' , '作者' , '缩略图' , '摘录' , '引用通告' , '自定义字段' , '意见' , '修订' ) ,“menu_posit ion'=> 6 ,'capability_type'=>'post'' – biziclop 2011-03-17 19:41:30

+0

嗨,biziclop。您的评论不适合。 :)你应该把它添加到你的答案,请。 – Francisc 2011-03-18 12:08:16