I have a custom plugin with a set of menus. I also have working a custom post type, but I am not sure how to push the custom post under the plugin's admin menu item.
The code for the custom post, with taxonomies is as follows:
function mmd_list_admin_manualentry() {
$labels = array(
'name' => _x( 'Manage Lists', 'mmd_list' ),
'singular_name' => _x( 'Manage List', 'mmd_lists' ),
'add_new' => _x( 'New List', 'mmd_list' ),
'add_new_item' => __( 'Add New List' ),
'edit_item' => __( 'Edit List' ),
'new_item' => __( 'New List' ),
'all_items' => __( 'Manage Lists' ),
'view_item' => __( 'View List' ),
'search_items' => __( 'Search List' ),
'not_found' => __( 'No Listing found' ),
'not_found_in_trash' => __( 'No Listings found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'CUSTOM POST TEST'
);
$args = array(
'labels' => $labels,
'description' => 'This post type holds all posts for your directory items.',
'public' => true,
'menu_position' => 10,
'show_ui' => true,
'show_in_menu' => 'mmd_list_options', // Use the plugin menu slug
'supports' => array( 'title' ),
'has_archive' => true,
);
register_post_type( 'mmd_list', $args );
}
add_action( 'init', 'mmd_list_admin_manualentry', 0 );
function mmd_list_taxonomies() {
$labels = array(
'name' => _x( 'List Categories', 'List Categories' ),
'singular_name' => _x( 'Category', 'taxonomy singular name' ),
'search_items' => __( 'Search List Categories' ),
'all_items' => __( 'All List Categories' ),
'parent_item' => __( 'Parent List Categories' ),
'parent_item_colon' => __( 'Parent List Category:' ),
'edit_item' => __( 'Edit List Category' ),
'update_item' => __( 'Update List Category' ),
'add_new_item' => __( 'Add New List Category' ),
'new_item_name' => __( 'New List Category Name' ),
'menu_name' => __( 'List Categories')
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'mmd_list_cat' )
);
register_taxonomy( 'mmd_list_cat', 'mmd_list', $args );
}
add_action( 'init', 'mmd_list_taxonomies', 0 );
add_action( 'add_meta_boxes', 'mmd_listings_add_entryfield' );
function mmd_listings_add_entryfield()
{
// add_meta_box( $id, $title, $callback, $page, $context, $priority, $callback_args );
add_meta_box(
'mmd_listings_List_Group',
__( 'Manual Entry', 'myplugin_textdomain' ),
'mmd_listing_EntryForm',
'mmd_list',
'normal',
'high'
);
}
The code for the standard WordPress plugin is not remarkable.
add_action( 'admin_menu', 'mmd_list_Define_admin_menu' );
// Add menu items
function mmd_list_Define_admin_menu()
{
add_menu_page( 'MMD Lists', // The page title.
'Lists', // The menu title displayed on dashboard.
'manage_options', // Minimum capability to view the menu.
'mmd_list_options', // Unique name used as a slug for menu item.
'mmd_maplist_DrawAdminPage', // A callback function used to display page content.
'dashicons-media-spreadsheet', // URL to custom image used as icon.
6
);
add_submenu_page('mmd_list_options', // Parent Slug from add_menu_page
'Manage Lists', // Title of page
'Manage Lists', // Menu title
'manage_options', // Minimum capability to view the menu.
'mmd_manage_lists_slug', // Unqiue Slug Name
'' ); // Custom Post menu.
}
I am just not sure how to get the custom post to fall under the plugin admin menu WITH all of its submenus including: categories, Manage List, Add List and proper post pages etc.
I have tried various assignments, including leaving the submenu call back function blank and references it with the slug name in the post registration, but that just leads to a "unknown page 404" code. If I use the main menu page and use that name, yes the custom post single menu item comes up, but I do not have access to the admin page I need for the plugin.
Been all over the function reference. There just does not seem to be the equivalent of a "parent" like in the admin menus. https://codex.wordpress.org/Function_Reference/register_post_type
Been scouring the web and the subject is either post-type or plugin type, not a blending of both.
Any thoughts on this?