I'm currently working on a plugin that creates a custom post type. The issue I'm strugging with at the moment is that the custom post type is created fine, but when I go to add a new post I receive an "Invalid Post Type" error.
The ui is hidden and I'm trying to link to it from add_submenu_page. I need assistance for how to properly link it.
Here is what I have in the submenu declaration:
add_submenu_page( 'restaurant-orders', 'Menu Management', 'Menu Management', 'manage_options', 'edit.php?post_type=menu-item');
My post type:
function restaurant_menu_items() {
$labels = array(
'name' => __('Restaurant Menu Items', 'post type general name'),
'singular_name' => __('Restaurant Menu Item', 'post type singular name'),
'add_new' => __('Add New', 'product page'),
'add_new_item' => __('Add New Menu Item'),
'edit_item' => __('Edit Menu Item'),
'new_item' => __('New Menu Item'),
'view_item' => __('View Menu Item'),
'search_items' => __('Search Menu Items'),
'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' => false,
'query_var' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','thumbnail'),
);
register_post_type( 'menu-item' , $args );
}
I can add a new post if I show the ui and do it the conventional way. However I do not want it this way, the post menu has to be under the plugin menu.
Thanks!