You answered your own question yourself.
You want links to custom categories to look like this
{taxonomy_slug}/{parent_term}/{child_term}/{grandchild_term}/
so you should pay attention to two parameters in the register_taxonomy()
arguments: hierarchical
and rewrite
.
$args = [
'hierarchical' => true, // <-- term may have a parent
'labels' => $labels,
'rewrite' => [
// hierarchical urls, defaults to FALSE
'hierarchical' => true, // <--
]
];
Your custom taxonomy is created by the parent theme, so to change it, use the register_taxonomy_args
filter:
add_filter( 'register_taxonomy_args', 'se344007_mytax_args', 10, 2 );
function se344007_mytax_args( $args, $taxonomy )
{
if ( 'mytax' !== $taxonomy ) {
return $args;
}
// it looks like it's already set up by parent theme
// $args['hierarchical'] = true;
if ( !is_array($args['rewrite']) )
$args['rewrite'] = [];
$args['rewrite']['hierarchical'] = true;
return $args;
}
When you register custom taxonomy, the default link to term (custom category)
is {taxonomy_slug}/{child_term_slug}
even if taxonomy is hierarchical, because
by default, the created links are not hierarchical ( $args[‘rewrite’][‘hierarchical’] = false ).