I like to create a landing page for my custom taxonomies. Right now ive created three custom taxonomies
/country/[terms]
/person/[terms]
/interrests/[terms]
i like to create a listing page for each of the taxonomy, this listing page should list all the [terms] they contain. And link to the normal (taxonomy-[term].php
/taxonomy/[term]
) url. What is a proper way to implement this?
First i was thinking something along the lines with template_redirect and create a custom taxonomy-list.php
file to include in the action which manually query using a WP_Query()
I can see at least 3 ways to do that.
Adding a rewrite rule. See http://codex.wordpress.org/Rewrite_API for details:
then use the
template_redirect
filter to load your template when thetax
variable is there:You’ll also need to add the
tax
query var to the list of filtered vars using thequery_vars
filter.Creating pages using specific template to list the terms
In your case you need to create three custom files:
taxonomy-country.php
,taxonomy-person.php
andtaxonomy-interrests.php
.Pay attention to suffixes of those templates. It has to be the same as in taxonomy registration. For instance if you register your taxonomy like
register_taxonomy( 'genre', array( 'book' ), $args );
, then your custom template has to havetaxonomy-genre.php
file name.