Space after each comma in tag string

Hello! I’m a PHP newbie, hoping you guys can help me with this.

Been searching the forum but I haven’t found how to add an extra space after each comma in the tag string.

I’m sure it’s stupid simple but I can’t seem to figure it out.

Thanks for your input! :slight_smile:

Seems that your are echoing the tags as a single string. Usually, you separate the strings by using the split() method, which gives you an array of tags you can then loop through. Afterwards, we re-add the commas via CSS.

In your templates:

<?php $tags = $page->tags()->split(); ?>
<ul class="tags">
 <?php  foreach($tags as $tag): ?>
  <li><?= $tag ?></li>
<?php endforeach ?>

In your css:

.tags li:not(:last-child):after{
    content: ", ";
1 Like

amazing! thanks a lot :smiley: