I've seen this asked all over the internet, but so far nothing has worked for me.
Ideally, I'd like the following to work:
http://example.com/mortgage-brokers < taxonomy archive
http://example.com/mortgage-brokers/victoria < taxonomy term
http://example.com/mortgage-brokers/victoria/melbourne < second-level taxonomy term
http://example.com/mortgage-brokers/victoria/melbourne/john-smith < single 'post'
I have the 'Custom post type permalinks' plugin set to /%broker_locations%/%postname%/, and I've defined my CPT & taxonomy as follows:
$args = array(
'label' => __('Brokers'),
'singular_label' => __('Broker'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'query_var' => true,
'rewrite' => [
'hierarchical' => false,
'slug' => 'mortgage-brokers',
'with_front' => false
],
'supports' => array('title', 'editor', 'thumbnail', 'tag', 'comments'),
);
register_post_type( 'broker' , $args );
register_taxonomy(
'broker_locations',
'broker',
array(
'hierarchical' => true,
'label' => 'Broker locations',
'hierarchical' => true,
'rewrite' => array(
'hierarchical' => true,
'with_front' => false
)
)
);
With the above configuration I can get post permalinks to work, as long I don't add a slug to 'rewrite' in the taxonomy definition, resulting in 'broker_locations' in the slug, i.e:
http://example.com/mortgage-brokers/victoria/melbourne/john-smith < works
http://example.com/mortgage-brokers/victoria/melbourne < 404s
http://example.com/mortgage-brokers/broker_locations/victoria/melbourne < "works", but isn't desired
I've also been able to get either nested taxonomy archives OR post permalinks to work fine (depending on which one's defined first in functions.php), but the other one always 404s.
Does anyone have any idea what's going on? I can't believe how difficult something so simple has been.