Home › Forums › Front-end Issues › If statement based on field type › Reply To: If statement based on field type
Figured it out!!
I took a chance and made an if statement based on what I thought was the radio button type (turned out to be ‘choices’) and it actually worked.
Here’s the code i used. So this calls all fields within a group, takes out any that doesn’t have a value, then puts an icon instead of a ‘yes or ‘no’ for the radio button, yet keeps all other fields loading like they normally do:
$group_ID = 6817;
$fields = array();
$fields = apply_filters('acf/field_group/get_fields', $fields, $group_ID);
if( $fields )
{
foreach( $fields as $field_name => $field )
{
$value = get_field( $field['name'] );
if ($field['choices']){
$map = array(
'yes' => '<i class="icon-ok"></i>',
'no' => '<i class="icon-remove"></i>'
);
$value = $map[ $value ];
} else {
}
if( $value ) {
echo '<li><b> ' . $field['label'] . '</b> ' . $value . '</li>';
}
}
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.