Display custom taxonomy terms list
-
Hi all,
Problematic
I have a Custom Post Type called : “Beer”.
I have some Taxonomies called : “Color”, “Manufacturer”, “Country”.
I have some terms. For exemple, several colors : “Blond”, “Dark”, “Red”, “Black”…I want to display on a page the list of terms.
When I go to the URL : https://www.monsite/blog/color/
I would like to display the list of my color (with link) “Blond”, “Dark” etc…What I did !
1- I created a template called : “taxonomy-beer.php”.
2- I put the following code in the file :<?php $taxonomy = 'beer'; $term_args=array( 'hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC' ); $tax_terms = get_terms($taxonomy,$term_args); ?> <ul> <?php foreach ($tax_terms as $tax_term) { echo '<li>' . '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a></li>'; } ?> </ul>
3- I update my permalink config
It does not work ! My website display a 404 error.
Do you know why ? I have no idea what I have to do.
Thanks for your help,
Thomas
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Display custom taxonomy terms list’ is closed to new replies.