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; ?>                     

closed as off-topic by Mark Kaplun, Jacob Peattie, fuxia Aug 12 at 23:05

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    What is the return format set to for service_panel_colour in the ACF field UI? Make sure it's Both (Array) – TheDeadMedic Aug 10 at 10:05
  • If the return value is not an array you can simply ` echo $service_panel_color;` which will output either the label or value depending on your setting. – virtualLast Aug 10 at 10:10
  • Hi guys, I dont understand why i would set both as im only parsing the value and not a label. Also only one value is being selected each time so i would imagine I don't need to set as an array, please correct me if im misunderstanding. Your input is most appreciated – Nick Aug 10 at 10:14