0

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)

2
  • IIRC /%category%/%postname%/ include subcategory. for instance, parent_cat/child_cat/title
    – idpokute
    May 15, 2018 at 20:40
  • The rule you gave works only for posts, not for a custom post ! i.e. if "post-slug" was a simple post the url'll be /parent_cat/child_cat/title, but in my case it's /custom-slug/title !
    – Sami
    May 15, 2018 at 21:56

0