Using a parent term slug in URL of a child term e.g. …/parent-slug/child-slug/

Problem: By default children terms doesn’t has parent slug in URL e.g.:

Test - parent term - /test/
    - Lorem - child term - /lorem/
    - Ipsum - child term - /ipsum/
    - Dolor - child term /dolor/

how we can get URL like .../test/lorem/ or .../test/ipsum/?

How to add parent term slug to child term URL

Solution: It's very simple :) When registering taxonomy, that contain our terms should add 'hierarchical' => true to rewrite argument:

'rewrite' => [ 'slug' => 'test-taxonomy', 'hierarchical' => true ],

Leave Comment

Your email address will not be published.