Closed Alt-Ben closed 1 year ago
$taxonomy
variable
Improved variable naming for better code readability.Can you explain the situation this is fixing? This isn't in the core so it might also be happening there.
Hi Jason!
So I was using hyphenated taxonomies, and the urls that we'd generally use were just 404'ing. For example:
Taxonomy: Foo Bar Slug: /foo-bar Template: foo_bar.antlers.html
The slug wasn't being picked up, once I added the str_replace in, it all worked as expected.
Hopefully that helps - let me know if I've missed anything, or done something wrong!
While this change works for your use case, I dont think it's going to be sufficient for all (for example when a taxonomy is linked to a collection).
There are a couple of options:
We could just loop over all taxonomies and find where the uri matches... this works on the assumption there arent going to be a load of them so its a quick query.
We add a uri
column to the taxonomies table, write an update script and migration, store the uri in the database, and use that for the query.
Either way the findTaxonomyHandleByUri method needs updated with the new logic.
Ok for now Ive opted for (1) as its the path of least friction for now. Let me know if this works for your use case.
@Alt-Ben did you get a chance to review this fix?
Sorry! Just got around to checking - all looks good from my side! Thank you!
Super tiny change to fix the hyphenated taxonomies in term uris.