I want to use custom post type in my web app and want to use that url in my plugin menu. I have created custom post type like this.
register_post_type( 'reserve',
array(
'labels' => array(
'name' => __( 'Reserves' ),
'singular_name' => __( 'Reserve' ),
'all_items' => __( 'All Reserves' ),
'add_new' => __( 'Add Reserve' ),
'add_new_item' => __( 'Add New Reserve' ),
'edit' => __( 'Edit'),
'edit_item' => __( 'Edit Reserve' ),
'new_item' => __( 'New Reserve'),
'view' => __( 'View Reserve'),
'view_item' => __( 'View Reserve'),
'search_items' => __( 'Search Reserves'),
'not_found' => __( 'No Reserves found' ),
'not_found_in_trash' => __( 'No Reserves found in trash' ),
'parent' => __( 'Parent Reserve')
),
'description' => __( 'This is where you can add new Reserves' ),
'public' => true,
'show_ui' => false,
'capability_type' => 'page',
'publicly_queryable' => true,
'exclude_from_search' => false,
'hierarchical' => true,
'rewrite' => array( 'slug' => 'reserves', 'with_front' => false ),
'query_var' => true,
'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'excerpt',/*, 'page-attributes'*/ ),
'has_archive' => true,
'show_in_nav_menus' => true
)
);
Notice that I have set show_ui as false so that my new custom type wont be displayed on admin sidebar. Now I am creating a my plugin menu as following.
$topslug = 'reserve/admin';
add_menu_page('Reserve Overview', 'Reservation', 'view_reservation_plugin', $topslug, 'show_start_page',RESERVE_URL.'images/menu_icon.png');
add_submenu_page($topslug, 'RESERVE', 'Reserve Builder', 'view_reservation_plugin', 'reserve/manage_reserve', 'show_manage_reserves');
From above code you can find that I have created a menu as Reservation having two submenus 1) Reserve Overview 2) Reserve Builder.
Now my issue is I want to change my URL of Reserve Builder.
Currently its 'admin.php?page=reserve/manage_reserves'. I want to change it like 'edit.php?post_type=reserve' so that i can use wordpress inbuilt facility.
Say if I am passing 'edit.php?post_type=reserve' in add_submenu_page('edit.php?post_type=reserve', 'RESERVE', 'Reserve Builder', 'view_reservation_plugin', 'reserve/manage_reserve', 'show_manage_reserves').Menu gets disappeared. TIA.
'show_ui' => false
and use it? Add submenu pages to that post type and you can use the built-in WP editor, meta boxes for customization, etc.add_submenu_page()
. I have done it with many plugins I've developed. For Custom Post Types:add_submenu_page('edit.php?post_type=your_post_type',...)
.. Or am I understanding it wrong? :)