Support

Account

Home Forums Front-end Issues Show Different Text If Custom Field

Solved

Show Different Text If Custom Field

  • How to show 4 different divs if the text inside the custom field is different?

    I have:

    1 custom field with 4 different texts values inside.
    4 different divs to display the 4 different texts.

    The custom field “field1” contains 4 different texts inside.

    1. text inside custom field “field1” is textA
    2. text inside custom field “field1” is textB
    3. text inside custom field “field1” is textC
    4. text inside custom field “field1” is textD

    So, how can i output the 4 Divs for each different texts?

  • Hi There,

    Thanks a lot for reaching out to us.

    You can easily check the value using an if else as shown here

    $fieldValue = get_field('field1');
    if($fieldValue=='textA'){
    echo "My First Div";
    }else if($fieldValue=='textA'){
    echo "My Second Div";
    }
    ...
    

    Hope this helps.

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

The topic ‘Show Different Text If Custom Field’ is closed to new replies.