loops - How to output HTML from array in PHP -
sorry if subject bit strange. didn't know else name it.
i style peace of code fit style of website.
<?php global $post; $opties = wp_get_post_terms($post->id, 'items', array("fields" => "names")); if (count($opties) > 0) { echo implode(', ', $opties); } ?>
right echo's
item 1, item 2, item 3, etc...
i have echo following:
<i class="fa fa-check" aria-hidden="true"></i>item 1<br> <i class="fa fa-check" aria-hidden="true"></i>item 2<br> <i class="fa fa-check" aria-hidden="true"></i>item 3<br>
how code that? in advance!
you can combine html using alternative syntax foreach
.
<?php global $post; $opties = wp_get_post_terms($post->id, 'items', array("fields" => "names")); foreach ($opties $o): ?> <i class="fa fa-check" aria-hidden="true"></i><?php echo $o ?></i> <?php endforeach; ?>
Comments
Post a Comment