Multiple taxonomies separated by comma and end with “and” - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Thursday, June 30, 2022

Multiple taxonomies separated by comma and end with “and”

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?



source https://stackoverflow.com/questions/72806240/multiple-taxonomies-separated-by-comma-and-end-with-and

No comments:

Post a Comment