Jorinde
Forum Replies Created
-
Forum: Themes and Templates
In reply to: How to sort terms in custom taxonomies?Alright! Yes, my problem is solved. Thanks for your help.
Forum: Themes and Templates
In reply to: How to sort terms in custom taxonomies?Michael, that worked like charm!
I promise to dig deeper into this whole PHP thing, thank you so much for providing me with the necessary pointers.This is my full code now. I use this bit about 12 times in the template, for the various taxonomies. Is there a downside to that?
<?php $taxonomy = 'habitat'; $tax_args=array('orderby' => 't.term_id'); $terms = wp_get_post_terms( $post->ID , $taxonomy, $tax_args); if ($terms) { echo '<li> <strong>Habitat:</strong> '; foreach ($terms as $term) { echo '<a href="' . esc_attr(get_term_link($term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a> '; } echo '</li>'; } ?>Forum: Themes and Templates
In reply to: How to sort terms in custom taxonomies?Fantastic! That is exactly what I was looking for.
Now I only have two issues left:
How can I exclude/hide empty taxonomies? In other words, with the original (non-sortable) solution that employedthe_terms, I could define before and after bits—<li> <strong>Habitat:</strong>and</li>—that were displayed only when there was a value. How can I prevent such an empty label now?The other thing is: the hierarchy of the terms is not reflected by the URL. It is
/habitat/france, instead of/habitat/europe/france. Can the URLs show the hierarchy? If there is no easy/known fix to the latter, I will dismiss the plan.Thank you for your patience.
Forum: Themes and Templates
In reply to: How to sort terms in custom taxonomies?Michael, thank you for your quick response.
I tried your proposal: yes, it works: it returns the slugs, ordered by ID. What I need are the names, with a link to the respective archive (sorry for not being clear about that in my first post). I have figured out that I can get the name when I changeslugtoname. But what about the links?
Thanks!