Trong register_post_typecuộc gọi của bạn , đảm bảo bạn có các đối số sau:
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
)
);
Đảm bảo permalinks của bạn được xóa (chỉ cần truy cập trang Cài đặt> Permalinks).
Bây giờ khi bạn tạo một cái mới my_post_type, chỉ cần đặt cha mẹ của nó thành cái khác và permalink sẽ trông giống như:
http://example.com/parent-post-type/my-post-type/
Bạn có thể đi nhiều cấp độ như bạn cần.