Custom taxonomy listing page when no term set (all terms)
I've created a custom taxonomy "foo" with rewrite slug "foo" and query_var "foo".
Say for example, I also have terms "bar" and "baz" in the "foo" taxonomy.
At the moment, permalinks like /foo/bar and /foo/baz work fine, using my taxonomy-foo.php template.
What I'd like to do is be able to hit /foo and retrieve all posts with a link to any "foo" taxonomy. Currently, this URL shows a 404.
How can I achieve this? If I can somehow hook into the rewrite code and set a default term value ('all' for example) if missing, that might be a way to move forward but I'm not sure if this is possible.
I'd preferably like to use the taxonomy-foo.php template file for the "catch all", dealing with the logic of showing posts from one or all terms in there.
Cheers
Edit: I've figured how to catch a request for /foo and set some defaults using add_filter('request', ...) though I had to use an existing term as using anything else generates a 404. Is there any way to avoid this limitation?
I've created a custom taxonomy "foo" with rewrite slug "foo" and query_var "foo".
Say for example, I also have terms "bar" and "baz" in the "foo" taxonomy.
At the moment, permalinks like /foo/bar and /foo/baz work fine, using my taxonomy-foo.php template.
What I'd like to do is be able to hit /foo and retrieve all posts with a link to any "foo" taxonomy. Currently, this URL shows a 404.
How can I achieve this? If I can somehow hook into the rewrite code and set a default term value ('all' for example) if missing, that might be a way to move forward but I'm not sure if this is possible.
I'd preferably like to use the taxonomy-foo.php template file for the "catch all", dealing with the logic of showing posts from one or all terms in there.
Cheers
Edit: I've figured how to catch a request for /foo and set some defaults using add_filter('request', ...) though I had to use an existing term as using anything else generates a 404. Is there any way to avoid this limitation?
No comments:
Post a Comment