2015-10-07 7 views
2

Я пытаюсь показать пользовательскую таксономию под пунктом меню администратора, который является только страницей i.e http://example.com/wp-admin/admin.php?page=bla.WordPress показать таксономии под настраиваемым меню администратора

Согласно WordPress Dev. страница для show_in_menu под register_taxonomy он говорит следующее:

«некоторая строка» - Если существующей страницы верхнего уровня, таких как «tools.php» или «? edit.php post_type = страница», тип пост будет помещенный в качестве подменю этого.

Означает ли это, что таксономии не могут быть показаны ни при чем, кроме тех?

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); 
} 

ответ

1

Я нашел способ обойти эту проблему, код ниже:

add_action('admin_menu', 'shmeh_menu'); 
    add_action('parent_file', 'menu_highlight'); 

    function shmeh_menu() { 
     add_submenu_page('bla', 'Shmeh', 'Shmeh', 'manage_options', 'edit-tags.php?taxonomy=shmeh'); 
    } 

    function menu_highlight($parent_file) { 
     global $current_screen; 

     $taxonomy = $current_screen->taxonomy; 
     if ($taxonomy == 'shmeh') { 
      $parent_file = 'bla'; 
     } 

     return $parent_file; 
    }