How can I maintain the parent child relationship in custom post types, so that I have a uniform URL structure? I want to make a URL structure up to 4 levels, e.g.


Is it possible without a plugin? When I go to a single page URL, it ends in 3 levels.

1 Answer 1


In your register_post_type call, make sure you have these arguments:

        'hierarchical' => true,
        'public' => true,
        'rewrite' => array(
            'slug'       => 'my_post_type',
            'with_front' => false,
        'supports' => array(
            'page-attributes' /* This will show the post parent field */,
        // 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:


You can go as many levels as you need.

  • 1
    Can you give me entire code of creating custom post type with parent child relation and URL level to 4 levels for making uniform structure of URL. Apr 16, 2015 at 10:34
  • 1
    Works fine for me - technically, there shouldn't be any limit. Have you tested this in a fresh install of WordPress with all plugins disabled, and then flushed permalinks? Apr 16, 2015 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.