Support

Account

Home Forums General Issues Multi-select field, front-end styling

Unread

Multi-select field, front-end styling

  • I’m currently using a repeater and multi-select field like so:

    <?php if( have_rows('awards') ):
    echo '<ul>';
    while ( have_rows('awards') ) : the_row();
    								
    	$name = get_sub_field('name');
    	$awards = '<span>' . implode('</span> <span>', get_sub_field('award')) . '</span>';
    								
    echo '<li>' . $name . $awards . '</li>';
    
    endwhile;
    echo '</ul>';
    endif;
    ?>

    How do I modify this to give the spans a class based on the selected fields? So that the output would become (for example):

    <ul><li>Jane Doe <span class="awardone">AwardOne</span> <span class="awardFour">AwardFour</span></li>
    <li>John Q. Public <span class="awardtwo">AwardTwo</span></li></ul>

    I’m stuck!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.