Support

Account

Home Forums Front-end Issues HowTo: show ALL acf fields and their labels Reply To: HowTo: show ALL acf fields and their labels

  • damn it ^^. then one could use it that way:

    <?php
    if($fields = get_field_objects()){
    unset($fields["bild"]);
    unset($fields["asin"]);
    unset($fields["preis"]);
    unset($fields["bewertung"]);
    unset($fields["produktname"]);
    ?>
    <div class='data row'>
    	<?php
    	foreach($fields as $field){
    		?>
    		<div class='item col-sm-6 col-md-4 col-lg-3'>
    			<div class='term'>
    				<?php echo $field["label"];?>
    			</div>
    			<div class="value">
    				<?php 
    				if(isset($field["prepend"])) echo $field["prepend"]." ";
    				if(isset($field["choices"])){
    					if(is_array($field["value"])){
    						$newarray = array();
    						foreach($field["value"] as $value){
    							$newarray[] = $field["choices"][$value];
    						}
    						echo implode(",",$newarray);
    					} else {
    						echo $field["choices"][$field["value"]];
    					}
    				} else { 
    					echo $field["value"]; 
    				} 
    				if(isset($field["append"])) echo " ".$field["append"];
    				?>
    				</div>
    		</div>
    		<?php
    	}
    	?>
    </div>
    <?php
    }
    ?>
    

    this will generate nice list with pre- and appended elements and will look for right labels for checkboxes/select fields