我创建了一个名为user-story的自定义Post类型。$args看起来如下所示:
$args = array(
'labels' => $labels,
'hierarchical' => true,
'description' => 'description',
'taxonomies' => array('category', 'story-type', 'genre'),
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'http://webmaster.webmastersuccess.netdna-cdn.com/wp-content/uploads/2015/03/pencil.png',
'public' => true,
'has_archive' => true,
'query_var' => true,
'capability_type' => 'post',
'supports' => $supports,
'rewrite' => $rewrite,
'register_meta_box_cb' => 'add_story_metaboxes' );
register_post_type('user_story', $args);问题是在线'taxonomies' => array('category', 'story-type', 'genre'),。我看不到我的分类法story-type和genre在添加新的故事页面的管理。只有category出现了。
story-type和genre都是自定义分类法。我关闭了CPT插件(user_story),然后重新激活它。但仍未出现高于传统分类法的分类。
这两个自定义分类法都是通过插件注册的,它们在管理菜单中都是可见的。在这些分类法下注册的术语也会出现在它们各自的列表页面中。
屏幕截图-1:在分类法story-type中注册的术语列表

屏幕截图-2:在分类法genre中注册的术语列表

屏幕截图-3:添加新故事页面-除了内置的分类法category之外,没有任何其他分类被列出。

我参考了this。
发布于 2017-02-15 09:22:57
这个应该有帮助:taxonomy/
将此代码放在您的functions.php文件中,并且应该将自定义分类添加到您的自定义post类型中。
<?php
add_action( 'init', 'create_user_story_tax' );
function create_user_story_tax() {
/* Create Genre Taxonomy */
$args = array(
'label' => __( 'Genre' ),
'rewrite' => array( 'slug' => 'genre' ),
'hierarchical' => true,
);
register_taxonomy( 'genre', 'user-story', $args );
/* Create Story Type Taxonomy */
$args = array(
'label' => __( 'Story Type' ),
'rewrite' => array( 'slug' => 'story-type' ),
'hierarchical' => true,
);
register_taxonomy( 'story-type', 'user-story', $args );
}
?>https://stackoverflow.com/questions/42243609
复制相似问题