In a reply in this topic https://toolset.com/forums/topic/is-this-possible-hierarchy-question/ is sounds like child post types should have hierarchical urls.
So if I got a Custom Post type called Country and a child post type to this called City when viewing a city post I would get the url siteurl/country/city/postname. But I just get siteurl/city/postname
Dear bob,
There is no way to do that with the Types plugin alone, but I'm sure you can do it by adding some rewrite rules: http://codex.wordpress.org/Class_Reference/WP_Rewrite
This is a WordPress thing and not something that we control in Types. WordPress permalinks build a hierarchy for pages. Since Types parent / child relationship permits different parents to the same child, there's no way to make the Types parent in the URL.
Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
I posted this solution on a similar thread elsewhere but just want to get this simple code snippet out there for anyone trying to do this. This solution is assuming a custom URL structure based on a relationship between content types of Brand and Product where I want the URL to be /nutrition/brand-name/product-name/. Hopefully this solution is a help to anyone else looking for a way to do this. If you need further explanation contact me hidden link.
//URL rewrites rules for nutrition/brand/product
add_action( 'init', function() {
add_rewrite_rule('^nutrition/(.*)/([^/]+)/?$','index.php?product=$matches[2]','top');
});
add_filter('post_type_link', function($link, $post){
if('product' == get_post_type($post)){
$parentId = wpcf_pr_post_get_belongs($post->ID,'brand');
if($parentId){
$parent = get_post($parentId);
return str_replace('product', $parent->post_name, $link);
}
}
return $link;
}, 10, 2 );