I have got a custom taxonomy known as "Artists". Let me have the ability to display the performers the following:

[Main Artist / First in Array] ft. [Second Artists], [Third Artist] & [Last Artist]

The code I am presently using to show the "Artist" is:

<?php $artists_links = get_the_term_list( $track->ID, 'artists', '', ' ', '' );
      $artists_withoutlinks = strip_tags( $artists_links );
      echo $artists_withoutlinks ?>

So would anybody have the ability to assist with this? To sum up all I wish to have the ability to do is:

  • Alter the separator following the first term to "foot."
  • Alter the separator prior to the last term to "&lifier"

Clearly I wish to keep database calls low, making the query as quickly as possible, any assistance is greatly appreciated.

Use get_the_terms() rather than get_the_term_list(). As the latter brings the terms right into a string, the very first produces a range of terms. Still just one query. Produce the string in the array later on:

<?php
    $artists = get_the_terms( $track->ID, 'artists' );
    $artist_string = '';
    $length = count($artists);
    for($i = 0; $i < $length; $i++) {
        $artist_string .= strip_tags( $artists[$i] );
        if ( $i == 0 )
            $artist_string .= ' ft. ';
        elseif ( $i == $length - 2 )
            $artist_string .= ' & ';
        elseif ( $i != $length - 1 )
            $artist_string .= ', ';
    }
    echo $artist_string;
?>