We have these PHP functions
$taxcomposer = strtoupper(get_the_term_list( get_the_ID(), 'composer', '', ', ' )) ;
$taxarr = strtoupper(get_the_term_list( get_the_ID(), 'arranger', '', ', ' ));
$taxlyrics = strtoupper(get_the_term_list( get_the_ID(), 'lyrics', '', ', ' ));
To display it we use this code
$frontpage = '
<p style="padding-top: 9pt;text-align: center;">by</p>
<p style="padding-top: 1pt;text-align: center;">'.$taxcomposer.''.$taxarr.''. $taxlyrics.' </p>';
The front end result:
By
MARK W. WINGSTON, FILIP STONEEVA NYMAN, JOHN SCOTTFRIDA M. HAMELTON, HENRIK GRIEG
I want it to look like this:
By
MARK W. WINGSTON, FILIP STONE, EVA NYMAN, JOHN SCOTT, FRIDA M. HAMELTON and HENRIK GRIEG
I guess we need to array it somehow and then replace the final comma with “and”, how do we achieve this?
Update
$taxcomposer = get_the_terms( get_the_ID(),'composer');
$taxarr = get_the_terms( get_the_ID(),'arranger');
$taxlyrics = get_the_terms( get_the_ID(),'lyrics');
$terms = array_merge( $taxcomposer, $taxarr, $taxlyrics);
$links = array();
foreach ($terms as $term) {
$link = get_term_link( $term );
$links[] = '<a style="text-transform: uppercase;" href="'.esc_url( $link ).'">'.$term->name.'</a>';
}
$last = array_pop( $links );
$string = count($links) ? implode(", ", $links) . " & " . $last : $last;
Error log
array_merge(): Expected parameter 2 to be an array, bool given Warning: Invalid argument supplied for foreach()
If the taxonomy is empty then it results in not displaying anything…
Solution
Not found yet…