jdp
jdp

Reputation: 3516

Wordpress Custom Taxonomy URL Hierarchy

I've got a custom taxonomy that is set to Hierarchical = true. However, when I try to access them hierarchically in the URL, it doesn't work.

i.e.

| Training (Taxonomy Name)
| - test-taxonomy
| - - another-test-taxonomy

My expected URL would be mysite.com/training/test-taxonomy/another-test-taxonomy/. That gives a Page Not Found error though.

I can access both test-taxonomy and another-test-taxonomy like so: mysite.com/training/<slug>, but it doesn't seem to work hierarchically.

Upvotes: 1

Views: 3889

Answers (2)

Boycott A.I.
Boycott A.I.

Reputation: 18871

11 years late, but I just found the solution to this problem in Gavin's link: https://wordpress.org/support/topic/hierarchical-custom-taxonomy-permalinks/#post-1520946

To implement the solution, in my call to register_taxonomy, I changed the

'rewrite' => array(
    'slug' => 'training'
)

part to

'rewrite' => array(
    'slug' => 'training',
    'hierarchical' => true
)

I then went into my Permalink Settings page ( https://example.org/wp-admin/options-permalink.php ) and just clicked the Saved Changes button and, having it large, the URLs of my hierarchical custom taxonomy are now also hierarchical - and they work on every level!! Sorted.

Upvotes: 1

Gavin
Gavin

Reputation: 2567

Check this: http://wordpress.org/support/topic/hierarchical-custom-taxonomy-permalinks

Here's the trac ticket: http://core.trac.wordpress.org/ticket/12659

Unfortunately, the bottom line is it can't be done without some serious hacking right now - ran into the same problem a few weeks ago. Likely in near future releases, I would think.

Upvotes: 1

Related Questions