2

I'm trying to add custom menu items for my Custom Post Type. I've added "show_in_menu" => false in my CPT definition so it will not show in admin menu.

Then I've added to admin_menu action:

add_menu_page('Example', 'Example', 'activate_plugins', 'edit.php?post_type=example', 'render_table', 'dashicons-tickets', 3);
add_submenu_page ( 'edit.php?post_type=example', 'All Examples', 'All Examples', 'activate_plugins', 'edit.php?post_type=example');
add_submenu_page ( 'edit.php?post_type=example', 'Add new Example', 'Add new Example', 'activate_plugins', 'post-new.php?post_type=example');

I would like to overwrite default menu for that CPT but links in menu look like this:

/wp-admin/admin.php?page=edit.php%3Fpost_type%3Dexample
/wp-admin/edit.php?post_type=example&page=edit.php?post_type=example
/wp-admin/post-new.php?post_type=example

Because of this 2nd link does not lit up when I'am on listing page for that post type. Is there any way to make 1st and 2nd link look like this:

/wp-admin/edit.php?post_type=example
/wp-admin/edit.php?post_type=example

As it is in default menu? Maybe I need to overwrite their functions in some other way?

Your Answer

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

Browse other questions tagged or ask your own question.