0

I really don't know hot to ask this question correctly. I've created a custom post type with a name badges and added custom taxonomies to it (level, skill). Now I want to add a new submenu item to that custom post. This is my custom post:

  add_action('init', 'bsp_badges_register');
  function bsp_badges_register() {

$labels = array(
    'name' =>_x('Badges', 'post type general name'),
    'singular_name' =>_x('Badge', 'post type singular name'),
    'add_new' =>_x('Add New', 'badge item'),
    'add_new_item' =>__('Add New Badge Item'),
    'edit_item' =>__('Edit Badge Item'),
    'new_item' =>__('New Badge Item'),
    'view_item' =>__('View Badge Item'),
    'search_items' =>__('Search Badge'),
    'not_found' =>__('Nothing found'),
    'not_found_in_trash' =>__('Nothing found in Trash'),
    'parent_item_colon' => ''
);

$args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'query_var' => true,
    'menu_icon' => 'dashicons-welcome-learn-more',
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'menu_position' => 75,
    'supports' => array('title','editor','thumbnail'),
    'has_archive'=>true,
    'show_in_menu'=>'badge-school'

    //'taxonomies' => array('post_tag','category')
  ); 

register_post_type( 'badge' , $args );
    flush_rewrite_rules();

One of my taxonomies:

     register_taxonomy(
'skills',
array('badge'), 
array(
'hierarchical'=>true,
'public'=>true,
'label'=>'Skills',
'labels'=>array(
    'name'=> _x( 'Skills', 'taxonomy general name' ),
    'singular_name'=>'Skill',
    'menu_name'=>__('Skills')
    ),
'show_ui'=>true,
'rewrite'=>array('slug'=>'skill'),
)
);

Then I tried adding a submenu like that:

    add_action('admin_menu','bsp_plugin_menu');

    function bsp_plugin_menu(){
    add_menu_page('Badge school', 'Badge School', 'manage_options','badge-school','bsp_students_function','dashicons-welcome-learn-more');
    //my taxonomy
    add_submenu_page('edit.php?post_type=badge', 'Skills', 'Skills', 'manage_options', 'edit.php?taxonomy=skill&post_type=badge'); 

But it does not show. I see the menu Badges and nothing else. There should also be add new post and it's not showing. I don't know what am I doing wrong and how to fix it. I need to get it all in one menu, because I need to add more submenus without taxonomies.

I hope you can understand my problem, as I mentioned, I don't really know how to ask the question.

  • I'm not sure I understand the problem. Are you post types / taxonomy not showing up in the admin panel or are they showing up and you want to add a sub-menu under the Badges Post Type? – Howdy_McGee May 14 '15 at 21:52
  • If I do custom post with custom taxonomies everything is fine and it's showing in the admin menu. But when I try to add a new admin menu and then add this custom post with it's taxonomies to show as submenu, then it's not showing. @Howdy_McGee – dea May 15 '15 at 11:50
0

So to answear my own question after much googeling:

In the args array I commented out the option for show_in_menu, so that custom post type creates the menu itself. Then I didn't add the admin menu, but just the submenu (the hook still remains).

    add_action('admin_menu','bsp_plugin_menu');

And the first parameter is the one that shows it in the menu and it is a name of the custom post type:

    add_submenu_page(**'edit.php?post_type=badge'**, 'Add new students', 'Add new students', 'manage_options','add-new-students','bsp_students_add');

And now it shows in the menu with all the taxonomies and custom post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.