Using has_tag to display certain information
-
Hi,
I need help with the code below.
<?php if(has_tag(array('Actress','Model','Singer')) ) { ?> <li class="occupation">Occupation: <?php if(has_tag('Actress')){ ?><a href="https://www.galleryfake.com/tag/Actress">Actress</a><?php } ?> <?php if(has_tag('Model')){ ?><a href="https://www.galleryfake.com/tag/Model">Model</a><?php } ?> <?php if(has_tag('Singer')){ ?><a href="https://www.galleryfake.com/tag/Singer">Model</a><?php } ?> </li> <?php } ?>
The code currently displays this in a post “Occupation: Actress” or “Occupation: Singer”… and then adds a link to the specific tag page.
The problem I have with this is that if a post has more than 1 of these tags then the spacing is wrong. It displays as “Occupation: ActressSinger” or “Occupation: ActressModel”.
I want it to display commas in-between the different occupations, so it would show like this “Occupation: Actress, Singer”.
How could I achieve that?
Also, is there an easier way to do it than I’m doing it?
Thanks!
P.S. – I’ve just started coding so still suck
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Using has_tag to display certain information’ is closed to new replies.