“client” is a custom post type because I have to add several metaboxes.
For a better ergonomy on admin side, I would like to add my custom post type “client” as “users” submenu.
I understand to display a custom post type, normally urls are :
- https://my-site.com/wp-admin/edit.php?post_type=client
- https://my-site.com/wp-admin/post-new.php?post_type=client
When I add “client” inside users menu, I got this url :
https://my-site.com/wp-admin/users.php?page=client
So, that does not work.
How can I get the client edition with list/post-new/edit-new based on the last url ?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Solution 1 (not a good idea):
add_users_page( _x( $this->page_title, "page_title", $this->text_domain ), _x( $this->menu_title, "menu_title", $this->text_domain ), $this->capability, "edit.php?post_type=my-post-type" );
Notice : This code is used in a class.
When you are on the page, it can have some bugs with the menu, it´s a good idea for specific page
Solution 2 :
register_post_type(
'my-post-type',
array(
'show_in_menu' => "users.php"
)
);
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0