Use default permalink for custom post (and no slug)

I’v created a custom post type with this code :

register_post_type(‘Villes’,
array(
‘labels’ => array(
‘name’ => __(‘Villes’),
‘singular_name’ => __(‘Villes’),
),
‘public’ => true,
‘has_archive’ => true,
‘rewrite’ => array(‘slug’ => ‘villes’),
‘taxonomies’ => array( ‘category’ )
)
);

As you’ve noticed I’ve activated Categories for the post. This is the structure on my categories :

cat1

sub1
sub2

cat2

I’ve created a custom post in the sub2 category, what should I do so the permalink of the post is mysite.com/cat1/sub2/post-slug (and not mysite.com/villes/post-slug)

Read more here:: Use default permalink for custom post (and no slug)

Leave a Reply

Your email address will not be published. Required fields are marked *