我正在尝试在一个仅为页面的管理菜单项下显示自定义分类法,即 http://example.com/wp-admin/admin.php?page=bla。
根据 WordPress Dev. 页面上 show_in_menu
的说明(register_taxonomy),它说:
'some string' - 如果是现有的顶级页面,例如 'tools.php' 或 'edit.php?post_type=page',则该文章类型将作为其子菜单放置。
这是否意味着除了那些页面外,无法在其他地方显示分类法?
PHP
<?php
// hook into the init action and call create_book_taxonomies when it fires
add_action( 'init', 'create_book_taxonomies', 0 );
// create two taxonomies, genres and writers for the post type "book"
function create_book_taxonomies() {
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
'name' => _x( 'Genres', 'taxonomy general name' ),
'singular_name' => _x( 'Genre', 'taxonomy singular name' ),
'search_items' => __( 'Search Genres' ),
'all_items' => __( 'All Genres' ),
'parent_item' => __( 'Parent Genre' ),
'parent_item_colon' => __( 'Parent Genre:' ),
'edit_item' => __( 'Edit Genre' ),
'update_item' => __( 'Update Genre' ),
'add_new_item' => __( 'Add New Genre' ),
'new_item_name' => __( 'New Genre Name' ),
'menu_name' => __( 'Genre' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_in_menu' => 'bla', // not working | tried admin.php?page=bla as well, also not working
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'genre' ),
);
register_taxonomy( 'genre', array( 'book' ), $args );
}