Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yellowberri-snippets/7d3d7946ed0204d3bd48 to your computer and use it in GitHub Desktop.
Save yellowberri-snippets/7d3d7946ed0204d3bd48 to your computer and use it in GitHub Desktop.
PHP: WP: Display Multiple ACF Fields with Custom Label
<?php
$listedInfo = array(
'client' => 'Client',
'city' => 'Location',
'date' => 'Project Date',
'cost' => 'Construction Cost',
'size' => 'Building Size',
'schedule' => 'Construction Schedule'
);
foreach ($listedInfo as $fieldName => $displayName) :
if ( get_field( $fieldName ) ) :
echo '<span class="listed-data">';
echo '<strong>' . $displayName . ":</strong> " . get_field($fieldName);
echo '</span>';
endif;
endforeach;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment