Problem: I would like to display my list of terms in hierarchical order instead of alphabetical order.
Solution: Add the following code to functions.php:
unction list_hierarchical_terms($atts) { global $post; $taxonomy = $atts['taxonomy']; // change this to your taxonomy $separator = ''; $out = ''; $term_ids = wp_get_object_terms( $post->ID, $taxonomy, array( "fields" => "ids" ) ); usort( $term_ids, 'cmp' ); foreach($term_ids as $term_id ) { $term = get_term( $term_id, $taxonomy, OBJECT ); $out .= $separator . $term->name; $separator = $atts['separator']; } return $out; } add_shortcode('display_post_tax_terms_hierarchical', 'list_hierarchical_terms');
Then use your new custom shortcode like so:
[display_post_tax_terms_hierarchical taxonomy="category" separator=" | "]
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 7 replies, has 2 voices.
Last updated by Christian Cox 7 years ago.
Assisted by: Christian Cox.