Tom, thanks.
I was partially successful, but I'm not sure I used all the necessary functions to make it perfect.
I've also understood that it's not the register_post_type that is being modified, but this is this last one that is assigned to add_menu_page() and add_submenu_page().
With the below script, if I use only add_submenu_page()
without add_menu_page
, it works almost perfectly (display add-org and list-org) except that default submenu items "all post" and "new post" always show up.
The two first in the image.

I read here that a custom css can hide default items (edit-post and add-post). Is it a good solution ?
function atv_organization_post_type(){
$labels = array(
'name' => 'Organizations',
'singular_name' => 'Organization',
'add_new' => 'Add Organization',
'add_new_item' => 'Add Organization',
'edit_item' => 'Modify Organization',
'new_item' => 'New',
'all_items' => 'All',
'view_item' => 'Show Organization',
'search_items' => 'Search',
'not_found' => 'No Organization',
'not_found_in_trash' => 'Nothing',
'parent_item_colon' => '',
'menu_name' => 'All Organization',
);
$args = array(
'labels' => $labels,
'public' => true,
'menu_icon' => 'dashicons-admin-multisite',
'has_archive' => true
);
register_post_type( 'organization-post', $args );
}
add_action('init','atv_organization_post_type');
add_action( 'admin_menu', 'atvam_cp_plugin','manage_options');
function atvam_cp_plugin() {
add_submenu_page( '/edit.php?post_type=org_post_type', 'All Organization', 'All Organization', 'manage_options', 'org-list','atv_org_list');
add_submenu_page( '/edit.php?post_type=org_post_type', 'Add Organization', 'Add Organization', 'manage_options', 'add_org','atv_org_add');
}
function atv_org_list(){
include plugin_dir_path( __FILE__ ) . 'adminpages/org-list.php';
}
function atv_org_add(){
include plugin_dir_path( __FILE__ ) . 'adminpages/add-org.php';
}
--------------- UPDATE -----------
So I complete my answer with one solution . (If someone has a best solution I'll take it.)
add show_in_menu
in $args to not show clone items/links (list and add post) :
$args = array(
'show_in_menu' => false
);
add add_menu_page()
to replace menu generated by register_post_type()
:
add_menu_page('All organizations','All organizations', 'manage_options','edit.php?post_type=organization-post','atv_org_list', 'dashicons-admin-multisite', 6);
Hide the submenu item generated by add_menu_page(), because the link used is weird * and impossible to adapt while the menu link is correct.
- It displayed this link =
https://website.org/wp-admin/edit.php?post_type=org_post_type&page=edit.php?post_type=org_post_type
To hide this generated submenu I target id of top level menu class adding :
li#toplevel_page_edit-post_type-org_post_type ul.wp-submenu li.wp-first-item {
display: none !important;
}
'supports' => array(''),
but I think it's really not good thing. Can you point me in the direction of the method you have in mind?Currently I use add_menu_page and add_submenu_page but they can be linked to a custom post list.
? I'm trying to change my methodadd_menu_page
, akaremove_menu_page
add_menu_page
refer to Custom post type withregister_post_type()
? As I say in my first question I used these function and I already had custom pages. But now I don’t find how to linkregister_post_type()
withadd_menu_page()
.