Tag Info

New answers tagged

1

This is working. Pieter Gossen's method of counting is better, so I implemented that as well: function the_producers($post_id = false) { if ($post_id == false) { $post_id = get_the_ID(); } $producers = get_the_terms($post_id, 'producers'); $q = count($producers); if( 1 == $q ) { $str = reset($producers)->name; ...


1

Instead of counting inside your foreach loop, why not count the result from get_the_terms. Something like this $q = count($producers); From that, you can then use a conditional like if( 1 == $q ) { // do something when only one term exists }else{ // do something for mutliple terms }



Top 50 recent answers are included