I’m displaying a list of terms that a post is assigned to by using the following:

<?php 
$terms = get_the_terms( $post->ID , 'winetype' ); 
$sep = ', '; 
foreach ( $terms as $term ) { 
echo $term->name; 
echo $sep; 
} ?>

But we would like the output to be in descending alphabetical order (Z-A), I can’t find a way to use order => DESC on this, any suggestions?

Many thanks in advanced.

2 Answers
2

You could try this:

// Get posts terms
$terms = wp_get_post_terms( $post->ID, 'winetype', array( 'order' => 'DESC') );

$sep = ', '; 
foreach ( $terms as $term ) { 
    echo $term->name; 
    echo $sep; 
} 

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *