Support

Account

Home Forums General Issues acf if query problem Reply To: acf if query problem

  • There isn’t any way to tell what you’re trying to do, for example, I have no idea what you’re attempting to do here or why

    
    if( $field['farben'] != 'Schwarz'): ?>
    

    $field as returned by ACF has no index named “farben”

    Nor do I understand why you are using get_field_object() instead of get_field()

    The only thing I can really do is tell you how I’d set this up.

    First I would create a checkbox field. The choices for this field would look something like this

    
    #FF0000 : Red
    #00FF00 : Grean
    #0000FF : Blue
    

    I would set the return value of this field to “Both (Array)”

    Then, in my template I would do this, I’m only adding what would be needed for using the values returned.

    
    $colors = get_field('name_of_color_field_here');
    if ($colors) {
      foreach ($colors as $color) {
        ?><div style="background-color: <?php
              echo $color['value']; ?> title=<?php 
              echo $color['label']; ?>></div><?php 
      }
    }