Home Forums General Issues Create a Choice field which can parse HTML


Create a Choice field which can parse HTML

  • Hi, I need to create a custom field from Choice group ( can be any of Select, Checkbox or Radio Butoon) wich can display HTML in post.
    For example I need to select Yes or No and for these two options I want to have [label variation=”label-red”]No[/label] and [label variation=”label-green”]Yes[/label]

    If I use Wyswyg Editor everything is ok but I need to enter manualy everytime one of them.
    If I use Select from Choice and enter these values, in backend when I choose one of the in frontend appear like in backend.
    Thank you.

  • Just set up your radio button with yes and no as choices.

    When you go to display the field, your code will be something like this:

    if( get_field('yes_no') == 'Yes':
        echo "<label style='color:green'>Yes</label>";
    elseif( get_field('yes_no') == 'No'):
        echo "<label style='color:red'>No</label>";
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Create a Choice field which can parse HTML’ is closed to new replies.