Suppose we registered the composers
and the interprets
custom taxonomies.
The composers
taxonomy could have the following terms:
- Wolfgang Amadeus Mozart
- Ludwig van Beethoven
- Richard Wagner
The interprets
taxonomy could have the following terms:
- Glenn Gould
- Daniel Barenboim
- Vienna State Opera
I am wondering whether the WordPress template hierarchy has a special file , like taxonomy-terms.php
, to list taxonomy terms with a simple loop:
<?php
while ( have_posts() ) : the_post();
the_title();
endwhile;
?>
This would print (assuming the /%postname%/
permalink setting):
Wolfgang Amadeus Mozart
,Ludwig van Beethoven
,Richard Wagner
when viewingexample.com/composers
Glenn Gould
,Daniel Barenboim
,Vienna State Opera
when viewingexample.com/interprets
If not, I would like to know the best way to implement this. I would create a page template for each taxonomy, template-composers-terms.php
and template-interprets-terms.php
and list terms using something like the following code:
<?php
/* Template Name: List of composers */ // or 'List of interprets'
$terms = get_terms( 'composers' ); // or get_terms( 'interprets' )
foreach ( $terms as $term ) :
echo $term->name;
endforeach;
?>
Then, I create two pages, "Composers" and "Interprets", to which I respectively assigned the "List of composers" and "List of interprets" templates.
I'm not very comfortable using this method, because it requires creating a new file for each taxonomy.