【发布时间】:2017-07-12 06:05:42
【问题描述】:
我刚刚创建了一个自定义分类法,以将“页面类型”添加到 WordPress 网站的不同页面。它们可以很好地添加到页面中,但不幸的是我无法将这些分类法添加到 CMS 中的任何菜单中。每个页面都将设置为“男性”、“女性”或“信息”,因此将这些作为菜单项会很棒。我已经提供了下面的代码,任何帮助将不胜感激!谢谢!
function add_custom_taxonomies() {
// Add new "Locations" taxonomy to Posts
register_taxonomy('Page-type', 'page', array(
// Hierarchical taxonomy (like categories)
'hierarchical' => true,
// This array of options controls the labels displayed in the WordPress Admin UI
'labels' => array(
'name' => _x( 'Page Types', 'taxonomy general name' ),
'singular_name' => _x( 'Page Type', 'taxonomy singular name' ),
'search_items' => __( 'Search page types' ),
'all_items' => __( 'All page types' ),
'parent_item' => __( 'Parent page type' ),
'parent_item_colon' => __( 'Parent page type:' ),
'edit_item' => __( 'Edit page type' ),
'update_item' => __( 'Update page type' ),
'add_new_item' => __( 'Add new page type' ),
'new_item_name' => __( 'New page type Name' ),
'menu_name' => __( 'Page Types' ),
),
// Control the slugs used for this taxonomy
'rewrite' => array(
'slug' => 'page-types', // This controls the base slug that will display before each term
'with_front' => false, // Don't display the category base before "/locations/"
'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
),
));
}
add_action( 'init', 'add_custom_taxonomies', 0 );
【问题讨论】:
标签: wordpress taxonomy custom-taxonomy