WordPress | Adding a custom post menu under custom menu in the admin -


i trying create plugin, dashboard page, config page, pages configuration , custom post types.

more specific, in admin have pages added in menu via functions add_menu_page , add_submenu_page, create custom post types related plugin.

the question is, how group custom post types menus under plugin menu options.

in example, lets creating menu option "myplugin" function add_menu_page , below menu adding pages "settings page", "do stuff page", "dashboard" via function add_submenu_page , create custom post type "cars". how can place "cars" menu under myplugin menu option ?

the final result like :

dashboard     home     ... posts     posts     ... settings     general     ...     ... myplugin             <- how add menu structure ?     dashboard        <- how add menu structure ?     cars             <- how add menu structure ?     settings page    <- how add menu structure ?     stuff page    <- how add menu structure ? 

the actual issue not how create menu structure, how add "cars" custom post type menu under myplugin menu.

note have try following option in "register_post_type" attributes no luck

'show_in_menu'          =>  'admin.php?page=myplugin.php' 

is posible achived ?

within register_post_type, add little snippet

"menu_position" => 100,// below second seperator 

here locations menu positions

 2 dashboard  4 separator  5 posts  10 media  15 links  20 pages  25 comments  59 separator  60 appearance  65 plugins  70 users  75 tools  80 settings  99 separator 

if set position greater 100 continue add them bottom of admin menu.

i created custom wp post type generator, can see position on custom post type on right hand side, enter post type name, (plural) under can select menu position, change position show appear,

if have trouble building menu structure try this

function myplugin_menu() {     add_menu_page('myplugin', 'myplugin', 'add_users', __file__, 'myplugin-page-name', plugins_url('mypluginfolder/images/icon.png') );     add_submenu_page(__file__, 'cars', 'cars', 8, 'myplugin-cars-page', 'cars');     add_submenu_page(__file__, 'settings', 'settings', 8, 'myplugin-settings-page', 'myplugin_settings_function');     add_submenu_page(__file__, 'do stuff', 'do stuff', 8, 'myplugin-dostuff-page', 'myplugin_dostuff_function'); } add_action('admin_menu', 'myplugin_menu'); 

http://codex.wordpress.org/function_reference/add_menu_page


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -