In your register_post_type
call, make sure you have these arguments:
register_post_type(
'my_post_type',
array(
'hierarchical' => true,
'public' => true,
'rewrite' => array(
'slug' => 'my_post_type',
'with_front' => false,
),
'supports' => array(
'page-attributes' /* This will show the post parent field */,
'title',
'editor',
'something-else',
),
// Other arguments
)
);
Make sure your permalinks are flushed (just visit the Settings > Permalinks page).
Now when you create a new my_post_type
, just set it’s parent to another and it’s permalink will look something like:
http://example.com/parent-post-type/my-post-type/
You can go as many levels as you need.