How to make such a structure for cpt? '/slug/%category%/%category2%/%postname%/' for post '/slug/%category1%/%category2%/' for taxonomy
There will be a maximum of 2 levels of categories. If a post has one category then '/slug/%category%/%postname%/'
I need this kind of structure only for this CPT and Taxonomy.
register_post_type(
'slug_cpt',
array(
'labels' => $labels,
'exclude_from_search' => false,
'has_archive' => true,
'public' => true,
'publicly_queryable' => true,
'rewrite' => true,
'can_export' => true,
'show_in_nav_menus' => true,
'supports' => array('title', 'thumbnail', 'comments', 'page-attributes', 'custom-fields'),
'show_in_rest' =>true,
)
);
register_taxonomy(
'slug_cats',
'slug_cpt',
array(
'hierarchical' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'labels' =>array(),
'query_var' => true,
'show_in_rest' => true,
)
);