Mar*_*hal 6 wordpress categories custom-post-type
有没有办法创建具有单独类别的自定义帖子类型wordpress
?
示例:
帖子类型" 新闻 "应该有" 世界 "和" 本地 " 类别.邮政类型" 产品 "应具有categories
:" 软件 "和" 硬件 ",我不希望选择将" 软件 "类别设置为" 新闻 "邮政类型.
有办法处理这个吗?
小智 13
您可以通过以下示例代码创建自定义帖子类型:
function ts_post_type_test() {
register_post_type( 'Test',
array(
'label' => __('Test'),
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => false,
'menu_position' => 5,
'capability_type' => 'post',
'texonomies' => array('category'),
'supports' => array( 'title','editor','thumbnail'),
)
);
}
Run Code Online (Sandbox Code Playgroud)
wordpress网站链接:http: //codex.wordpress.org/Function_Reference/register_post_type
对于特定帖子使用后创建单独类别的链接:
http://codex.wordpress.org/Function_Reference/register_taxonomy
示例代码:
register_taxonomy('name of taxonomy', 'post name',array("hierarchical" => true,"label" => "Label Category","singular_label" => "label of taxonomy",'update_count_callback' => '_update_post_term_count','query_var' => true,'rewrite' => array( 'slug' => 'slug name of new registered taxonomy', 'with_front' => false ),'public' => true,'show_ui' => true,'show_tagcloud' => true,'_builtin' => false,'show_in_nav_menus' => false));
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9977 次 |
最近记录: |