自定义帖子类型中的调用类别

时间:2011-03-09 作者:don de lion

我正在通过添加add\\u操作(\'init\',\'create\\u radiotalks\')创建一个自定义帖子类型;函数的文本。php页面:

add_action( \'init\', \'create_radiotalks\' );

function create_radiotalks() {
    register_post_type( \'radiotalks\',
        array(
            \'labels\' => array(
            \'name\' => __( \'Radio Talks\' ),
            \'singular_name\' => __( \'Radio Talk\' ),
            \'add_new\' => __( \'Add New\' ),
            \'add_new_item\' => __( \'Add New Radio Talk\' ),
            \'edit\' => __( \'Edit\' ),
            \'edit_item\' => __( \'Edit Radio Talk\' ),
            \'new_item\' => __( \'New Radio Talk\' ),
            \'view\' => __( \'View Radio Talk\' ),
            \'view_item\' => __( \'View Radio Talk\' ),
            \'search_items\' => __( \'Search Radio Talks\' ),
            \'not_found\' => __( \'No radio talks found\' ),
            \'not_found_in_trash\' => __( \'No radio talks found in Trash\' ),
            \'parent\' => __( \'Parent Radio Talk\' ),
),
            \'public\' => true,
        )
    );
}
当输入添加新的无线电通话信息时,我想添加适用的类别和标签,但它们不会显示在管理侧栏中?如何使类别/标记可用于自定义帖子类型?谢谢你的帮助。

-唐

2 个回复
SO网友:scribu

通过添加“taxonomies”参数:

\'public\' => true,
\'taxonomies\' => array( \'category\', \'post_tag\' ),

SO网友:Marcin

或通过注册分类:

<?php
register_taxonomy_for_object_type(\'category\', \'radiotalks\');
register_taxonomy_for_object_type(\'post_tag\', \'radiotalks\');

结束

相关推荐