Viewing 1 replies (of 1 total)
  • There’s no argument for get_the_terms() that will sort the results, so you’ll need to get the array of terms and then sort that manually using usort:

    $terms = get_the_terms( get_the_ID(), 'portfolio' );
    
    if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
    	usort( $terms, function( $term_a, $term_b ) {
    		return $term_a->term_id - $term_b->term_id;
    	} );
    
    	foreach ( $terms as $term ) {
    		// Do something.
    	}
    }
    
Viewing 1 replies (of 1 total)
  • The topic ‘list Terms with order by’ is closed to new replies.