As far as I know, WordPress doesn’t have a page that lists terms in a taxonomy, only pages that list all the posts in a taxonomy term. i.e. if you have the taxonomy cakes with the terms angel and devils-food, the template taxonomy-cakes.php will be used to display the archives of posts that have the terms in that taxonomy applied to them, i.e. /cakes/devils-food/. So no, I don’t believe there’s a neater way than creating a custom page template, unless you want to try fiddling around with routing and template selection to point WordPress at a particular template that way.
I’m curious about what you @alwaysblank would use to fiddle with routing and templates?
I tried Cortex but couldn’t get it to be displayed through Blade in the latest Sage9 (cf: Sage9 template & wrapper ) despite Ben’s kind sharing of the book example on how to render from php. I also tried with rareloop/wp-router but seems out of date as well and has been integrated into their Lumbersjack.
What would be the best way to have some custom routing for Wordpress?
If I really wanted to get serious with routing I would probably not use WordPress. When I have needed to do stuff that involves messing with paths and routing-things, I’ve just used WP’s Rewrites API: https://codex.wordpress.org/Rewrites_API It’s a bit obtuse sometimes, but it’s pretty powerful and you’re using the same mechanism WP uses internally.
So, small update to this: I actually found myself just yesterday needing to do some significantly complicated routing. I tried doing it with the Rewrites API and it was a bit of a nightmare, so on the suggestion of @Log1x I tried Cortex, and it works pretty much out of the box! I was able to replicate the problem you ran into (Sage9 Template & Wrapper) but normal template selection seems to work fine (i.e. don’t specify a template in your route, just let WordPress handle it.
So I’d tentatively revise my answer to be that Cortex is probably an easier solution to a lot of problems than Rewrites API.
This is brilliant! I’m a bit concerned by lowering globally the minimum stability requirement; would you know if it’s something that can be specific to the package (not sure where to look)?
Thanks so much for coming back and updating your answer; I stupidly lost myself in the complexity of a custom class and controlling the Blade template and forgot to come back to basics. Good lesson! Thanks!
My recollection is that OP wanted a page that displayed a list of all terms in a taxonomy, not a list of all items associated with a term. You’re definitely correct that you can template the page of a specific term, but I don’t believe WordPress has a built-in template that will display all terms in a taxonomy.
I actually had to revisit this, and manage to get it to work by removing remove_all_filters('template_include');
from Cortex/brainwp ResultHandler.php in the add_filter function handling ‘template_include’
then build a custom template file in ./views called awards.blade.php with the Blade basic calls ( @extends(‘layouts.app’) @section(‘content’) and @endsection) and my own logic and queries
However the queried objects from the custom routes won’t follow through (once passed through Blade, the query becomes a standard page query); unless I had a custom query in the template it won’t get access to the custom query results. SO roughly it seems so far to be a convoluted way of having a page with custom template/logic, with the only main davantage to lock down issues of users editing things in the admin. Not yet that DRY.
edit: nb: in ./site/composer.json I used ‘dev-refactoring-fastroute’ instead of 1.0.alpha-X