(sorry for the long read, but i think my question is probably not that difficult... )
I'm trying to get multiple custom taxonomies in one alphabetical ordered list, with links to the archives / taxonomy template.
Right now i have 4 custom taxonomies: World, America, Europe, Asia (<- Not the real taxonomies, just as an example) filled with city's.
When i just this pies of code:
<?php $terms = get_terms( 'world' );
echo '';
foreach ( $terms as $term ) {
// The $term is an object, so we don't need to specify the $taxonomy.
$term_link = get_term_link( $term );
// If there was an error, continue to the next term.
if ( is_wp_error( $term_link ) ) {
continue;
}
// We successfully got a link. Print it out.
echo '<p class="taxonomies"><a href ="' . esc_url( $term_link ) . '">' . $term->name . '</a></p>';
}
echo ''; ?>
I have to use it four times; world, America and so on. This means the taxonomies are displayed as different pieces of code, and just get placed underneath each other. There is no way to place the links (output) in alphabetical order.
So it look something like this: (also just an example)
New York
Amsterdam
China
Brazil
Zimbabwe
Alaska
Now, is there a way to make one function that places all the taxonomies in one "loop" where it is possible to order them alphabetically?
Something like this:
<?php $terms = get_terms( 'world', 'America', 'Europe', 'Asia' );
echo '';
foreach ( $terms as $term ) {
// The $term is an object, so we don't need to specify the $taxonomy.
$term_link = get_term_link( $term );
// If there was an error, continue to the next term.
if ( is_wp_error( $term_link ) ) {
continue;
}
// We successfully got a link. Print it out.
echo '<p class="taxonomies"><a href ="' . esc_url( $term_link ) . '">' . $term->name . '</a></p>';
}
echo ''; ?>
Where the output looks something like this:
Alaska
Amsterdam
Brazil
China
New York
Zimbabwe
TIA.
Cheers...