ACF – Repeater with a select option as sub field

OK so hands up I have never created a select option as a sub-field before and its driving me nuts. I am building a bootstrap theme and the purpose of the code I will add is to generate a service panel item with a series of repeater fields.

One field is a set of dropdown select options to allow the user to choose a colour by adding a class to the parent element. Then other sub fields for class icon and heading / content etc.

At the moment a NULL value is being parsed. Values options I am parsing for example are “serviceBox -red”, also for blue, green etc. But always only a single value.

The custom field in question is called $service_panel_colour, clearly I am missing something in the markup as nothing is displaying front end. Just a bit lost atm. Hoping someone can help.

Currently, ACF Select Field option is set to parse only the value as i don’t require a label.

<div class=”row”>
<!– check if custom field has rows –>
<?php if( have_rows(‘services’) ): ?>
<!– while custom field has rows –>
<?php while( have_rows(‘services’) ): the_row();

// variables for sub field values
$service_panel_colour = get_sub_field(‘service_panel_colour’);
$service_icon = get_sub_field(‘service_icon’);
$service_heading = get_sub_field(‘service_heading’);
$service_content = get_sub_field(‘service_content’);
$service_link = get_sub_field(‘service_link’);

<div class=”col-md-3 col-sm-6 col-xs-6″>
<div class=”<?php echo $service_panel_colour[‘value’]; ?>”>
<div class=”service-icon”>
<span><i class=”<?php echo $service_icon; ?>”></i></span>
<div class=”service-content”>
<h3 class=”title”><?php echo $service_heading ?></h3>
<p class=”description”><?php echo $service_content; ?></p>
<a href=”<?php echo $service_link[‘url’]; ?>” class=”read-more fa fa-plus” data-toggle=”tooltip” title=”Read More”></a>
</div><!–/ end serviceBox –>
<?php endwhile; ?>
<?php endif; ?>

Read more here:: ACF – Repeater with a select option as sub field

Leave a Reply

Your email address will not be published. Required fields are marked *