I’m sorry, the link I posted above did not behave as expected. I’ve corrected the link, it now goes to the intended user note. In any case, the example code did not output in the way I expected, though it did output terms with children immediately below parent. I tweaked the example code further so it outputs what I had expected to start with (except I changed the taxonomy here to yours, mine was ‘category’):
$taxonomy = 'marcamodelo';
// Get the term IDs assigned to post.
$post_terms = wp_get_object_terms( get_the_ID(), $taxonomy, array( 'fields' => 'ids' ) );
// Separator between links.
$separator = ', ';
if ( ! empty( $post_terms ) && ! is_wp_error( $post_terms ) ) {
$term_ids = implode( ',' , $post_terms );
wp_list_categories( array(
'title_li' => '',
'style' => 'list',
'echo' => true,
'taxonomy' => $taxonomy,
'include' => $term_ids
) );
}
Among terms of the same level and same parent, the ordering is indeed alphabetical, but the hierarchy takes precedence.