Lets say I have created two custom post types A
and B
. Those post types are displayed in the Admin menu one after another. (After Posts
for example)
Is there a way to display B
under A
?
The only similar behavior I am aware of is to assign Taxonomies to Post Types. This forces the first to be displayed under the second. I am looking for a way to do this using custom post types.
It’s like having relationships across post types.
I am managing post types and taxonomies using the excellent GD CPT Tools
plugin.
Wordpress 3.4.2
2 Answers
Yes, this capability is available with register_post_type
, via the show_in_menu
argument, but whether or not the particular plugin you are using supports this I don’t know.
add_action( 'init', 'wpa70679_custom_types' );
function wpa70679_custom_types() {
register_post_type( 'parent_type',
array(
'public' => true,
'labels' => array(
'name' => 'Parent post type'
)
)
);
register_post_type( 'child_type',
array(
'public' => true,
'show_in_menu' => 'edit.php?post_type=parent_type',
'labels' => array(
'name' => 'Child post type'
)
)
);
}