Forums

[resolved] How to turn comma separeted values in a custom fields to <li> (2 posts)

  1. ankitshekhawat
    Member
    Posted 2 years ago #

    It may be more of a php question but is there a way we can change comma separated values from a custom field entries like
    apples, oranges, bannanas

    to

    <li>apples</li>
    <li>oranges</li>
    <li>bannanas</li>

    Any help is much appreciated.

  2. stvwlf
    Member
    Posted 2 years ago #

    <?php
    $string = get_post_meta($post->postID, 'CustomFieldName', true);
    $values = explode(',', $string);
    foreach ($values as $value) {
       echo '<li>' . $value . "</li>\n";
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic