Wordpress Child Post Type
-
27-10-2019 - |
题
Made a custom post type, "Events", great. Now I want to get a second custom post type and nest its menu items with the existing Events items.
- No taxonomies allowed
- I know there's great event plugins, this is just theoretical
- It's gotta go INSIDE the "Events" menu, not above or below!
Should be straightforward... right? ...guise?
解决方案
Check out http://codex.wordpress.org/Function_Reference/register_post_type and the bit about "show_in_menu".
You should be able to set it to something like:
'show_in_menu' => 'edit.php?post_type=events'
And it'll show up in that menu. For more control, you can always play with the $menu and $submenu global variable. Add both post_types, do a print_r on $menu and $submenu to see where everything is, and then move some things around. It'll probably look something like this:
add_action('admin_menu', 'change_zee_menu');
function change_zee_menu() {
global $menu, $submenu;
$submenu['edit.php?post_type=events'][13] = array(
0 => 'All Sub Events',
1 => 'edit_posts',
2 => 'edit.php?post_type=sub_events'
);
$submenu['edit.php?post_type=events'][14] = array(
0 => 'Add Sub Event',
1 => 'edit_posts',
2 => 'post-new.php?post_type=sub_events'
);
}
不隶属于 StackOverflow