Home › Forums › ACF PRO › ACF PRO: Label + Value pairs of Field groups in front end – almost there, but… › Reply To: ACF PRO: Label + Value pairs of Field groups in front end – almost there, but…
Hi @James,
thank you! you definitely put me on the right track here.
I have achieved the desired result, and also managed to unecho unwanted groups here.
I’ll mark this as solved, post my code below in case it might help others, and kindly ask you to review my code in case you think there could be smarter ways to get to the same point:
<?php
$groups = acf_get_field_groups(array('post_id' => get_the_ID()));
foreach( $groups as $group_key => $group ) {
$fields = acf_get_fields($group);
// below starts condition to unecho unwanted field groups
if($group['title'] !== 'pagelicks'){
echo '<h2>'.$group['title'].'</h2>';
echo '<dl class="techspecs">';
if($fields ) {
foreach( $fields as $field_name => $field ){
$value = get_field($field['name']);
if( $value && $field['label'] !=='Bollicine' && $field['label'] !=='tipologia prodotto' ) {
echo '<dt>' . $field['label'] . '</dt>';
echo '<dd>' . $value. '</dd>';
}
}
echo '<dl>';
}
// below ends condition to unecho unwanted field groups
}
}
?>
Your help was priceless, thanks again!
Alessio
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.