Home › Forums › General Issues › Display image on condition of selection › Reply To: Display image on condition of selection
Hi,
If you have a select field without multiple select it should just return a value not an array..
This code might get you in the right direction:
<?php
$activity_rating = get_field('activity_rating');
switch($activity_rating){
case '1':
$img = 'urltoimage';
break;
case '2':
$img = 'urltoimage2';
break;
case '3':
$img = 'urltoimage3';
break;
case '4':
$img = 'urltoimage4';
break;
case '5':
$img = 'urltoimage5';
break;
case default:
$img = 'fallbackimage';
break;
echo '<img src="' . $img . '" alt="" />';
}
?>
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.