Support

Account

Home Forums General Issues Replace radio returned value by image

Solved

Replace radio returned value by image

  • Hello,

    is it possible to replace the returned value of a radio button by an image please ?

    Exemple for difficulty level.

    In admin / radio field creation :
    Very simple : very simple
    Simple : simple
    Normal : Normal

    And the returned result in front for :
    “Very simple” is : one star (a picture of one star)
    “Simple” is : two star (picture of two stars)
    “Normal” is : three star (picture of three stars)

  • Hi @Manuc

    Yes, this is an easy task that you can accomplish with the following code:

    
    <?php 
    
    $map = array(
    	'Very simple' => 'url/to/image.jpg',
    	'Simple' => 'url/to/image.jpg',
    	'Normal' => 'url/to/image.jpg',
    );
    
    $value = get_field('field_name');
    
    $image = $map[ $value ];
    
    ?>
    <img src="<?php echo $image; ?>" />
    
  • Many thanks to you Elliot !!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Replace radio returned value by image’ is closed to new replies.